Common basis of command git commands

First, looking at branches

git branch # listed in your local branch

git branch -r # List All remote branch

git branch d branchname # delete the local branch

Second, merging branches

 eg: the latest step to master merge their branch of dev

1) git checkout maser # switch to the master branch

2) git pull # pull master the latest code

3) git checkout dev # to switch to their own branch

4) git merge master # speaking master codes to merge their branch; Second, merging branches

Third, pull the remote branch and create a local branch

eg: you need to pull on a distal branch of the code already exists, modify, and commit

1) git branch -r # List All remote branch

NOTE: If the local view of the distal end of a branch is not the latest, can be switched are master, to pull in the maser codes, and then view;

2) git checkout -b local branch name x origin / remote branch name x

This embodiment may use a new branch in the local x, and automatically switch to the local branch x. It will establish a local branch and remote branch establish the mapping.

3) git pull # pull the distal end of the code branches;

Fourth, the local branch and a remote branch established role mappings

eg: own local branch, to be submitted to the distal end of an already existing branch

1)git branch -vv

See if a local branch and a remote branch has been mapped relationship

2) git branch -u origin / branch name

Establishing a mapping between branch and remote branch

Thinking the problem: local branch can only track a remote branch of the same name it?

The answer is no, the local branch can establish the mapping between remote branch with a different name

 

Guess you like

Origin www.cnblogs.com/titou-/p/11609671.html