Git version control

Source: Internet
Author: User

Git is an open source distributed version control system for efficient, high-speed processing of project versioning from very small to very large.

The biggest difference between distributed and centralized is that developers can commit to a local, and each developer copies a full Git repository on the local machine by cloning (git clone).

Global variable configuration:

because Git is a distributed version control system, so you need to fill in the user name and mailbox as an identity.

git config--global user.name "Willard" #设置用户名git config--global user.emal [email protected] # set up a mailbox git config--glo Bal color.ui true # display Color

Repository

Create a directory locally: Enter directory

Git init #初始化

Download remote to Local:

git clone https://github.com/kennethreitz/requests.git


GIT storage structure: history, staying area, working directory below: H,s,w respectively represents


Add and submit:

Git status #查看

git add file1 #添加 from W to S

Git commit-m ' init commit ' # S commit H

Git commit-am ' init commit1 ' # W submit directly to H

View Status:

Various ways to check your working tree

$ git diff (1)

$ git diff--cached (2)

$ git diff HEAD (3)

git differ # # S and W ratio to

git diff--staged # # S and H comparison

git diff HEAD # # W and H comparison

git diff--stat HEAD # ditto

Undo Error:

git reset file1 # # recover from H to S

git checkout file1 # # recover from S to W

git checkout HEAD # # recover from H to W

Remove and rename:

git rm file1 # removed from W and S, deleted from H when committed

git rm--cached file1 #从 S Delete


git mv file1 file2 # renamed from W and S, commit takes effect

git rm file1; git add file2 # ditto


Scratch workspace:

Git stash # #保存当前内容, entering the temporary workspace

git stash list #查看临时工作区列表

git stash Pop # restore workspace


Branch

Git branch #查看所有分支

GIT Branch branch name #新建分支

git checkout branch Name # #切换分支

git branch-d Branch name # # Delete Branch


Merging branches

Git Merge branch name

  The basic common commands for Git are: mkdir:         xx  (Create an empty directory  xx refers to directory name) PWD:             displays the path to the current directory.  git init           the current directory into a manageable git repository, creating a hidden. git file.  git add xx        add XX file to staging area.  git commit –m  "XX"    submit file  –m  followed by a comment. git status         View Warehouse Status git diff  xx        View xx file modified those content git log           View history git reset  --hard head^  or  git reset  --hard head~   Fallback to previous version (if you want to roll back to 100 versions, use git reset –hard head~100 ) cat xx           View xx file contents git reflog        View history's version number ID git checkout -- xx   the XX files in the work area of the changes are all revoked. git rm xx           Delete XX file Git remote add  origin https://github.com/tugenhua0707/testgit  Associate a remote library Git push –u (you don't need to use-u  for the first time) )  origin master  Push the current master branch to the remote library Git clone https://github.com/tugenhua0707/testgit    clone git checkout –b dev   from remote library create dev branch   and switch to Dev branch git branch    View all current branches git checkout master  switch back to master branch git merge dev     Merge Dev branch on current branch git branch –d dev  Delete Dev branch git branch name   Create branch git  stash  keep the current work hidden   wait to resume after the scene git stash list  view all hidden file listings git stash apply   Recover hidden files, but content does not delete git stash drop  delete files git stash pop  recover files while   also delete files git  remote  View information for remote libraries git remote –v  viewing the details of a remote library git push origin master  git pushes the master branch to the remote branch of the remote library 


This article is from the "Willard_sa" blog, make sure to keep this source http://374400.blog.51cto.com/364400/1681927

Git version control

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.