Git general usage actions

Source: Internet
Author: User

1. First build your own repository on GitHub, named Yourrepo

2. Create a local library

ssh -T [email protected] # before initializing the repository, confirm that the Certified public key is correct git init # initializes the repository git remote add origin [email protected]:yo Urname/-A # or use git add * to add all  warehouse 'firstcommit'  # Commit and add comment git push o Rigin Master # uploaded to GitHub, if there is already a part of the code in the Git repository, it will be reported (Non-fast-forward) error

3. Problems and solutions that may arise

If there is already a part of the code in the Git repository, it is not allowed to overwrite the code directly, there will be (Non-fast-forward) error, the workaround is as follows:

(1) Strong push, forcing the use of local code to overwrite the contents of the Git repository git push-f
(2) First fetch the contents of the Git repository to local and then merge, then push, #git fetch #git Merge, these 2 commands are equivalent to git pull

Git pull may be an error, the solution is as follows:
(1) The contents of the modification (. git/config) are as follows
[branch "master"]
Remote = origin
Merge = Refs/heads/master

(2) If you do not edit the config file, you can use the following command line:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master

And then pull it down and push it OK.

4. Before you use Git push code for the first time, you need to configure Git
(1) First create the SSH key locally;
$ ssh-keygen-t rsa-c "[Email protected]"
The following [email protected] changed to your mailbox, then asked to confirm the path and enter the password, we use the default all the way to the line. Successful words will be generated under ~/. SSH folder, go in, open id_rsa.pub, copy the key inside. Go back to GitHub, go to account Settings, choose SSH keys,add ssh key,title on the left, and paste the Key.

(2) In order to verify success, enter it under GIT bash:
$ ssh-t [email protected]
If it is the first time will prompt whether continue, enter Yes will see: You ' ve successfully authenticated, but GitHub does not provide shell access. This means that you have successfully connected to GitHub.
(3) before uploading the local repository to GitHub, you need to set up username and email, as GitHub will record them each time it commits.
$ git config--global user.name "your name"
$ git config--global user.email "[Email protected]"

Git general usage actions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.