0
点赞
收藏
分享

微信扫一扫

初识 GitHub


主要参考官方的bootcamp https://help.github.com/articles/set-up-git/

Set Up Git



在GitHub的心脏是一个开源的版本控制系统(VCS)称为Git的。 Git是负责一切GitHub上有关这发生在本地计算机上。



如果你不喜欢使用命令行,现在,GitHub上,您可以完成许多Git的相关操作,而无需使用命令行,其中包括:



  • Creating a repository
  • Forking a repository
  • Being social

Setting up Git



  1. 1 下载; Download and install the latest version of GitHub for Windows. This will automatically install Gitand
  2. 2 打开Git Shell; On your computer, open the Git Shell application.
  3. name so your commits will be properly labeled. Type everything after the 

$

git config --global user.name "YOUR NAME"

  1. 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





两种方式认证git;https/SSH





When you connect to a GitHub repository from Git, you'll need to authenticate with GitHub using either HTTPS or SSH.



Connecting over HTTPS (recommended)

If you clone with HTTPS, you can cache your GitHub password in Git using a credential helper.

Connecting over SSH



If you  clone with SSH, you must  generate SSH keys on each computer you use to push or pull from GitHub.




Create a new repository on GitHub

  1. New repository.
    2 Create a short, memorable name for your repository. For example, "hello-world".
  2. 3 Optionally, add a description of your repository. For example, "My first repository on GitHub."

  3. public or private
  4. 公共库是入门的绝佳选择!他们看到在GitHub上的任何用户,这样你就可以从一个协作社区受益。
    私人库需要更多的设置。他们只提供给你,仓库主人,以及您选择与之共享的任何合作者。
  • Public
  • 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.
  • Congratulations! You've successfully created your first repository, and initialized it with a README



Commit your first change


commit

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

README


初识 GitHub_HTTPS

  1. README.md.
  2. 2 Above the file's content, click .
  3. 3 On the Edit file tab , type some information about yourself.

  4. Preview changes.  5 Review the changes you made to the file. You'll see the new content in green.
  5. 6 At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.

master

  1. , you should choose to create a new branch for your commit and then  create a pull request.
  2. 初识 GitHub_github_02


  3. Propose file change.






fork就是一个仓库的副本。分叉存储库可以让你自由地尝试改变,而不会影响原来的项目。

最常见的是,叉是用来或者提出修改别人的项目,或者用别人的项目为起点,为您自己的想法。

Fork an example repository

Forking a repository is a simple two-step process. We've created a repository for you to practice with!

  1. 1  On GitHub, navigate to the octocat/Spoon-Knife repository.
  2. Fork.
  3. That's it! Now, you have a fork of the original octocat/Spoon-Knife repository.

Keep your fork synced

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

clone

  1. your fork
  2. 2 复制地址 In the right sidebar of your fork's repository page, click  to copy the clone URL for your fork.

  3. 3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).

git clone

  1. , and then paste the URL you copied in Step 2. It will look like this, with your GitHub username instead of 

YOUR-USERNAME

  1. :

git clone https://github.com/YOUR-USERNAME/Spoon-Knife

  1. 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

upstream, repository into the local clone of your fork.

  1. 1 On GitHub, navigate to the octocat/Spoon-Knife repository.
  2. 2 In the right sidebar of the repository page, click  to copy the clone URL for the repository.

  3. 3 Open Terminal (for Mac users) or the command prompt (for Windows and Linux users).
  4. 4 Change directories to the location of the fork you cloned in Step 2: Create a local clone of your fork.

cdls

  • .

cd your_listed_directory

  • .

cd ..

  • .
  1. 记住进入刚才的目录下面

git remote -v

  1.  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)

git remote add upstream

  1. , 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

git remote -v

  1.  again. You should see the URL for your fork as 

origin

  1. , and the URL for the original repository as

upstream

  1. .

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

Watch


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.




第一次学习使用GitHub,很多都不会,请哪位大神多多提点指教啊。谢谢啦






举报

相关推荐

0 条评论