简体   繁体   中英

Using the remote branch instead of local branch in git

I want git to forget everything that I have edited in local branch, and want to pull the update from remote branch.

I did not know how to do that and I am getting merge conflicts on few files.

What should I do if I do not want to merge the files at all (local edits need to be deleted) and start new with the remote HEAD?

Supposing you are talking about changes done on master branch for instance:

git checkout master
git reset --hard origin/master
git pull

You reset master HEAD on the one of remote/master , and then can fetch remote/master + merge it to local master .

Why don't you just delete your local copy, and reclone the remote? That's effectively like deleting all your changes, without having to have local history for unwanted changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM