[git hub]Set Up Git

来源:互联网 发布:兼职网络编辑招聘 编辑:程序博客网 时间:2024/06/06 03:15

Setting up Git

  1. Download and install the latest version of Git.
  2. On your computer, open the Terminal application.
  3. Tell Git your name so your commits will be properly labeled. Type everything after the $ here:

    git config --global user.name "YOUR NAME"
  4. 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

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 Repo

To put your project up on GitHub, you'll need a repository for it to live in. Let's create one!

On GitHub, you can store all kinds of projects in repositories. Personal repositories belong to user accounts, so after you've signed up for GitHub, you can create your first repository!

Create a new repository on GitHub

  1. New repository menuIn the upper-right corner of any page, click , and then click New repository.

  2. Repository name fieldCreate a short, memorable name for your repository. For example, "hello-world".

  3. Repository descriptionOptionally, add a description of your repository. For example, "My first repository on GitHub."
  4. Choose between creating a public or private repository.
    • 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.
    • Public and private repository optionsPrivate 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. Initialize with a readme checkboxSelect Initialize this repository with a README.
  6. Create repository buttonClick Create repository.

Congratulations! You've successfully created your first repository, and initialized it with a README file.

Commit your first change

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. Readme file in file listIn your repository's list of files, click README.md.
  2. Above the file's content, click .
  3. New content in fileOn the Edit file tab , type some information about yourself.
  4. File preview buttonAbove the new content, click Preview changes.

  5. File preview viewReview the changes you made to the file. You'll see the new content in green.

  6. Commit message for your changeAt the bottom of the page, type a short, meaningful commit message that describes the change you made to the file.

  7. Commit branch optionsBelow the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is master, you should choose to create a new branch for your commit and then create a pull request.

  8. Propose file change buttonClick Propose file change.

Celebrate

Congratulations! You have now created a repository, including a README file, and created your first commit on GitHub. What do you want to do next?

  • "Set up Git"
  • Create A Repository
  • "Fork a repository"
  • "Be social"

0 0
原创粉丝点击