Zulip Chat Archive

Stream: general

Topic: git help


view this post on Zulip Scott Morrison (Apr 11 2018 at 10:23):

Sorry to have to ask about mundane things like how to use git, but... Say that I've got a fork of mathlib that is borked in some way (in my case, I merged in a commit from master, that Mario shortly thereafter deleted, but I have a branch that includes it).

Should I:
1) Just delete my whole fork (this is a good moment to do so, I have only two modified files).
2) Learn about ... rebasing? something else? Is it possible to actually get my master branch back to matching the main repository's master branch?

view this post on Zulip Sebastian Ullrich (Apr 11 2018 at 10:25):

Is it possible to actually get my master branch back to matching the main repository's master branch?

git reset --hard origin/master

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:25):

But what about all the pushed commits to master on my github fork?

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:26):

That won't bring my fork hosted on github back to matching the corresponding branch on the main github repo, will it?

view this post on Zulip Sebastian Ullrich (Apr 11 2018 at 10:27):

Ah. It will after a git push --force <your remote>.

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:29):

But ... don't I have to strip commits or something?

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:29):

I want my master branch in my fork to really look (history and everything) just like the master branch in origin.

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:30):

Or is it okay to just continue on with my fork having its own alternative borked history?

view this post on Zulip Sebastian Ullrich (Apr 11 2018 at 10:30):

After these two commands, your fork's master will look exactly like the one in origin

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:32):

Ah, and the --hard you added above means I don't even need to git checkout -- .. Thanks.

view this post on Zulip Scott Morrison (Apr 11 2018 at 10:34):

Wow, amazing! Everything is beautiful. :-)

view this post on Zulip Sebastian Ullrich (Apr 11 2018 at 10:35):

:)


Last updated: May 15 2021 at 22:14 UTC