Git Pull mandatory coverage local file

git branch code is often cut when faced with this problem: error: Your local changes to the following files would be overwritten by merge 
sometimes do not need to save local changes, so can the local file mandatory coverage in the following ways off.

> Git FETCH --all > git reset --hard origin/master > git pull

1, git fetch the equivalent is to get the latest from remote to local, will not automatically merge, the following command:

 

 git fetch orgin master // will download the master remote repository to the local branch of the current branch in

 Difference git log -p master ..origin / master // compare local master branch and origin / master branch

 git merge origin / master // merge

Also use the following commands:

git fetch origin master: tmp // Get the latest branch from a remote repository master, to establish a branch in the local tmp

git diff tmp // will compare the current branch and tmp

git merge tmp // merge tmp branch to the current branch

 

2. git pull: the equivalent for the latest version to merge the local and remote

git pull origin master

git pull equivalent to get the latest version from the remote to the local and merge

In actual use, git fetch more secure

git reset--hard origin/master

git reset (-mixed) HEAD ~ 1
back one version, and content and local content will be staging area has not submitted all returned to the staging of the state, does not affect the original local file (uncommitted also
affected )
git the RESET the -soft the HEAD ~ 1
back one version, it does not empty staging area, the contents submitted to the staging area to recover, does not affect the original local file (uncommitted not affected)
git the RESET -hard the HEAD ~ 1
back one version, the version empty the contents of the staging area, which has been filed restored to local, local files will be restored version replacement

Guess you like

Origin www.cnblogs.com/xinhua219/p/11011671.html