The magic of Git

Source: Internet
Author: User

1, first look at Git QuickStart:

Http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 001373962845513aefd77a99f4145f0a2c7a7ca057e7570000

2,git operation

Git is a technology, and GitHub is a server;

So the purpose of git is to provide convenient code hosting, multi-person collaboration, code management and other functions;

The main operation of Git is: local commit, push to remote server, get remote server project three kinds

(1), Local:

git add pro///(with Slash, the whole directory to commit, or a file submitted, submitted just to staging area, not completed);
Git commit-m "Xxxxlog"//OK, put the submitted content into the version area, formally determined;

(2), remote

git remote add origin [email protected]:wayhbbeed/check.git//connect to the check item under user name Wayhbbeed on GitHub on the remote website and name this contact origin/ /origin the name of the contact, any can be changed; wayhbbeed website user name; Check for an item name in the user
Git push-u origin master//push local project to the main branch of the site master,-u means all, the second commit can not-u;//push when you need to establish a legitimate SSH certificate public key on the site, see the above Web Tutorial//really push not up, Using HTTPS mode to try//modify files, especially delete files, duplicate files, will cause push failure, this time using the method git pull//back to the site version git add check/git commit-m "some LG" Git push Origin master//Note: The operation should be noted in which directory, using PWD to view, if it is in a folder, add the entire folder will not be found, this time CD. Return to the parent, when submitting, remote push, to enter the folder to be push

(3), the difference between pull fetch

There are 2 commands in git that get the latest version from the remote branch to the Local:
1. Git fetch: the equivalent of getting the latest version from remote to local, not automatically merge

Git fetch Origin mastergit log-p master. Origin/mastergit Merge Origin/master

the meaning of the above command:
First download the latest version from the Remote Origin master branch to the Origin/master branch
Then compare the differences between the local master branch and the Origin/master branch
The final merge
The above process can actually be done in a clearer way:

Git fetch Origin master:tmpgit diff tmp git merge tmp

Compare merge after getting latest version from remote to local test branch
2. Git pull: the equivalent of getting the latest version from remote and merge to local

Git pull Origin Master

The above command is actually equivalent to git fetch and git merge
Git fetch is more secure in real-world use
Because before the merge, we can review the update and then decide whether to merge

The magic of Git

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.