开发者

git pull analogous to / opposite of git push -f? [duplicate]

开发者 https://www.devze.com 2023-03-24 13:25 出处:网络
This question already has answers here: Git pull after forced u开发者_JAVA技巧pdate (4 answers) Closed 7 years ago.
This question already has answers here: Git pull after forced u开发者_JAVA技巧pdate (4 answers) Closed 7 years ago.

Sometimes, esp. when I'm the only one working on a remote repository, I like rewriting the history with git rebase -i and git push origin master -f.

How do I do a forced git pull origin master without a merge? I tried it with the -f option, but that didn't work. I just want to rewrite the history of my local git repo to match that of the remote (origin).


git fetch
git reset --hard origin/master


With respect it is a few years old, the answer by MattDiPasquale will destroy any local changes or commits.

If you have local changes or commits, but need to rewrite history, run:

git fetch origin
git rebase origin/master
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号