主要参考官方的bootcamp https://help.github.com/articles/set-up-git/
Set Up Git
Setting up Git
- 1 下载; Download and install the latest version of GitHub for Windows. This will automatically install Gitand keep it up-to-date for you.
- 2 打开Git Shell; On your computer, open the Git Shell application.
-
3 git你的名字;Tell Git your name so your commits will be properly labeled. Type everything after the
$
here:git config --global user.name "YOUR NAME"
-
4 git你的e-mail;Tell Git the email address that will be associated with your Git commits. The email you specify should be the same one found in your email settings. To keep your email address hidden, see "Keeping your email address private".
git config --global user.email "YOUR EMAIL ADDRESS"
Next steps: Authenticating with GitHub from Git
Connecting over HTTPS (recommended)
If you clone with HTTPS, you can cache your GitHub password in Git using a credential helper.
Connecting over SSH
Create a new repository on GitHub
-
1 点击创建 In the upper-right corner of any page, click , and then click New repository.2 Create a short, memorable name for your repository. For example, "hello-world".
-
3 Optionally, add a description of your repository. For example, "My first repository on GitHub."
-
- 4 Choose between creating a public or private repository.
- 公共库是入门的绝佳选择!他们看到在GitHub上的任何用户,这样你就可以从一个协作社区受益。
私人库需要更多的设置。他们只提供给你,仓库主人,以及您选择与之共享的任何合作者。
- Public repositories are a great choice for getting started! They're visible to any user on GitHub, so you can benefit from a collaborative community.
- Private repositories require a little more setup. They're only available to you, the repository owner, as well as any collaborators you choose to share with. Private repositories are only available for paid accounts. For more information, see "What plan should I choose?.
-
- 5 Select Initialize this repository with a README.
- 6 Click Create repository.
Commit your first change
A commit is like a snapshot of all the files in your project at a particular point in time.
When you created your new repository, you initialized it with a README file. README files are a great place to describe your project in more detail, or add some documentation such as how to install or use your project. The contents of your README file are automatically shown on the front page of your repository.
Let's commit a change to the README file.
-
- 1 打开 In your repository's list of files, click README.md.
- 2 Above the file's content, click .
- 3 On the Edit file tab , type some information about yourself.
-
-
4 Above the new content, click Preview changes.5 Review the changes you made to the file. You'll see the new content in green.
-
6 At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.
-
7 Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch ismaster
, you should choose to create a new branch for your commit and then create a pull request. -
Click Propose file change.
最常见的是,叉是用来或者提出修改别人的项目,或者用别人的项目为起点,为您自己的想法。
Fork an example repository
Forking a repository is a simple two-step process. We've created a repository for you to practice with!
- 1 On GitHub, navigate to the octocat/Spoon-Knife repository.
- 2 In the top-right corner of the page, click Fork.
-
- That's it! Now, you have a fork of the original octocat/Spoon-Knife repository.
Keep your fork synced
You might fork a project in order to propose changes to the upstream, or original, repository. In this case, it's good practice to regularly sync your fork with the upstream repository. To do this, you'll need to use Git on the command line. You can practice setting the upstream repository using the same octocat/Spoon-Knife repository you just forked!
Step 1: Set Up Git
If you haven't yet, you should first set up Git. Don't forget to set up authentication to GitHub from Git as well.
Step 2: Create a local clone of your fork
Right now, you have a fork of the Spoon-Knife repository, but you don't have the files in that repository on your computer. Let's create a clone of your fork locally on your computer.
- 1 On GitHub, navigate to your fork of the Spoon-Knife repository.
- 2 复制地址 In the right sidebar of your fork's repository page, click to copy the clone URL for your fork.
-
-
3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
-
4 Type
git clone
, and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead ofYOUR-USERNAME
:git clone https://github.com/YOUR-USERNAME/Spoon-Knife
-
5 Press Enter. Your local clone will be created.
git clone https://github.com/YOUR-USERNAME/Spoon-Knife# Cloning into `Spoon-Knife`...# remote: Counting objects: 10, done.# remote: Compressing objects: 100% (8/8), done.# remove: Total 10 (delta 1), reused 10 (delta 1)# Unpacking objects: 100% (10/10), done.
Now, you have a local copy of your fork of the Spoon-Knife repository!
Step 3: Configure Git to sync your fork with the original Spoon-Knife repository
When you fork a project in order to propose changes to the original repository, you can configure Git to pull changes from the original, or upstream, repository into the local clone of your fork.
- 1 On GitHub, navigate to the octocat/Spoon-Knife repository.
- 2 In the right sidebar of the repository page, click to copy the clone URL for the repository.
- 3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
-
4 Change directories to the location of the fork you cloned in Step 2: Create a local clone of your fork.
- To go to your home directory, type just
cd
with no other text. - To list the files and folders in your current directory, type
ls
. - To go into one of your listed directories, type
cd your_listed_directory
. - To go up one directory, type
cd ..
.
- To go to your home directory, type just
-
记住进入刚才的目录下面5 Type
git remote -v
and press Enter. You'll see the current configured remote repository for your fork.
git remote -v# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
-
6 Type
git remote add upstream
, and then paste the URL you copied in Step 2 and pressEnter. It will look like this:git remote add upstream https://github.com/octocat/Spoon-Knife.git
-
7 To verify the new upstream repository you've specified for your fork, type
git remote -v
again. You should see the URL for your fork asorigin
, and the URL for the original repository asupstream
.git remote -v <span style="font-family: inherit; font-style: inherit; font-variant: inherit; line-height: inherit;"># origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)# origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)# upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)</span>
Now, you can keep your fork synced with the upstream repository with a few Git commands. For more information, see "Syncing a fork."
Follow People
When you follow someone on GitHub, you'll get notifications on your dashboard about their activity.
Once you are on one of their pages, click the "follow" button.
Watch A Project
At some point you may want to stay up-to-date with a specific project. When you're on a project page, you can click the Watch button at the top of the page.
When the owner updates the project, you'll see what happened in your dashboard.
More Things You Can Do
You've done some of the most basic social interaction GitHub has to offer, but don't stop there! Check out these other social features:
Pull Requests
You may find yourself wanting to contribute to someone else's project, whether to add features or to fix bugs. After making changes, you can let the original author know about them by sending a pull request.
Issues
When you are collaborating on a project with someone, you sometimes come across problems that need to be fixed. Each repository has an Issues section to help you keep track of these problems.
Organizations
Have you found yourself wishing you could collaborate with multiple people on one project? You can manage everyone with organizations! With an organization you can establish teams with special permissions, have a public organization profile, and keep track of activity within the organization.
Explore
Discover interesting projects in the Explore GitHub and Trending page sections. You can then star projects that you find interesting and want to come back to later—just visit your stars page to see all your starred projects.