Git uses finishing

background

Long before using svn, just click to use the Eclipse. Later I started using git, git though there are tools for Eclipse, but there are many poor use, eventually turned gitbash. Although there are many online tutorials, but need to be further from the use of finishing, finishing it and then blog about it using the steps. To remember the one hand, on the one hand for later use.

First, install

git client to search a search on the Internet, but there is no "Internet" download up really slow. Download gitbash on the client  before I wrote an article, mainly through the phone's hotspot download, speed is not bad.

Second, the basic operation

Described in terms of code development process

1, to a local resource cloned

git clone + resource path 
Example: git clone https://github.com/shuimutong/gdao.git

 2, pull the latest code

git pull

3, looking at branches

Check local branch git branch

View all git branch -a branch

4, switching to the (detected) designated branch

git checkout + branch name

Example: git checkout dev-1

5, see the branch status

git status

See if there are local modifications

6, comparison

git diff

Code and libraries contrast has been modified but not yet submitted

git diff branch name

And comparing the specified branch code, it can be used codeReview

7, add ready to submit changes

Adds the specified file: git add + file (folder) name

Add all: git add.

8, commit changes to the local library

git commit -m "comment"

Commit changes and add comments

9, will be submitted to the remote push

git push

10, temporary codes, temporary codes reduction

git stash

The current modification scratch up

git stash pop

The recent reduction of the temporary code

git checkout .

Restore local modifications

Third, branch, tag concept

1 Overview

Branch for the development of the label used for backup version.

Branch may be continuously changing, and the label code is not used for continuously changes.

2, branch

A need to develop a new project demands, then we create a branch, the development of this demand is made on this branch.

a, create a new branch

git checkout -b branch name

// create a branch in which the branch is dependent on the current, it can be switched to any of the branch to create a new branch.

b, a new push to remote branch

git push --set-upstream origin branch name

3, label

Line on the front of the new demands of development, we have the final version on the line to make a tag, to facilitate the latter view.

a, play tag

git tag -a label name -m "comment"

b, will be pushed to the remote tag

git push origin label name

c, view existing tag

git tag

d, the detection tag code

git checkout label name

Fourth, merge code

Suppose there is a branch gdao item master, dev-1-simple

There master code update, need new code into the dev-1-simple.

Specific steps:

1, submit the modification of the current branch

2, git checkout master // switch to the master

3, git push // pull the latest code

4, git checkout dev-1-simple // switch to development branch

5, git merge master // merged into the master branch development

6, conflict management

7, the code after the submission of the merger to the remote

 

Because I is limited, any questions, please exhibitions.

 

Guess you like

Origin www.cnblogs.com/shuimutong/p/11404664.html