Say I have 1 branch, master , I have cloned it and have since made changes locally that were not merged with the remote master branch.
I don't want to just pull from master and resolve the merge conflicts, what if I want to compare the differences between the remote branch and my local branch, push the files on my local branch that have conflicts to a new branch, and then accept all the changes from the remote branch.
Is there a way to do this in git?
To compare your local branch against remote master, do:
git diff origin/master
To push your local changes to a different remote branch, I recommend to first create a new local branch and push that one to the remote server:
git checkout -b your_new_branch
git push -u
This creates a new local branch and pushes it to the remote server. It also ensures that your local branch follows the remote one if you do a git pull
.
Finally, to get the changes from master and overwrite your local changes on the master branch, do:
git checkout master
git reset --hard origin/master
git pull
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.