Stream: beginners

Topic: How to restore pull requests and branches


view this post on Zulip Locria Cyber (Nov 01 2021 at 10:03):

Ok I just ran git --mirror when I meant to just update one branch

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:04):

how do I undo that

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:05):

this somehow closed a bunch of open pull requests

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:09):

what did you run exactly? from what I'm seeing mirror would just clone in a special way, but not modify the original

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:09):

though maybe it does

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:10):

also, why mirror the repo?

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:11):

just git push --mirror

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:12):

git push --mirror
git status
git add .
git checkout . --ours
git rebase --continue
git rebase -i refactor/backend-options
git checkout refactor/no-panic
nix-shell

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:12):

I tried to force-update current branch but used the wrong command

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:13):

I think it reverted the history to the last time I pulled the repository

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:25):

I'm really sorry!

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:26):

I think I recovered all the commits and tags, but lost all the branch names and tag names.

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:28):

github also seems to just still have commits and stuff

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:28):

only thing is that authors need to re-open PRs that were automatically closed

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:28):

so, nothing seems lost unless I'm missing something

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:33):

ohhh, so I guess that command closed PRs because it deleted the branches on the remote, and since we all use the same remote so CI works… tada! OK, mystery solved.

I'll go through and undelete/reopen a bunch of these to get us closer to normal.

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:35):

You can use git push --all to update remote branches that I deleted or reverted.

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:36):

I can restore branches but not re-open PRs that are not my own

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:37):

@Locria Cyber so far github itself seems to have all the data still, so I'd prefer using that over pushing "global" git commands

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:37):

Folkert de Vries said:

Locria Cyber so far github itself seems to have all the data still, so I'd prefer using that over pushing "global" git commands

git push --all update all the branch names

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:38):

I'm boopin' the buttons now. Found out there's a query for when something closed. Looks like only 20 PRs or so? Easy.

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:38):

I basically deleted all the remote branches that are not in my local repository.

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:38):

right so I think you don't need to do anything @Locria Cyber

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:39):

we can restore from github

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:39):

Doesn't Github have all the branch names?

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:40):

not sure what you mean. All PRs are reopened now and they seem to have their original branch name. You mean branches that did exist but did not have PRs associated with them?

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:43):

Yes

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:43):

@Brian Hicks does git push --all seem safe to you?

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:43):

nooooooooooooooooooooooo

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:44):

git is chock full of footguns

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:44):

I've just finished boopin' the UI buttons to restore branches

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:44):

I think tags get pulled automatically so we should be able to do git push --tags to restore those

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:45):

but I definitely just caused a build storm by reopening all the PRs so let's wait a bit so the queue can calm down

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:46):

right, let's not touch anything for a while then

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:47):

I hadn't considered branches without PRs, though (hadn't caught up before your @-mention) You're right that that one's tricky. git push --all may fix it, but only for the subset of branches/commits that's on each of our machines. I'm inclined to say that if someone had some WIP that didn't make it to PR, they should just push the latest and make a draft PR.

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:49):

also @Locria Cyber please don't worry too much about this—git makes it all too easy to get into situations like this, so GH and friends have made restores easier than they would be otherwise. The disruption here should be pretty minimal.

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:49):

ok

view this post on Zulip Locria Cyber (Nov 01 2021 at 10:50):

I think git user account has limited access control

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:52):

unfortunately, it really doesn't :grimacing:

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:52):

I guess I'd sum it up by saying "git happens"

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:53):

I see a bunch of rescue_HASH branches in the branch explorer. Did one of you push those?

view this post on Zulip Brian Hicks (Nov 01 2021 at 10:55):

oooh, looks like we need to restore the www branch to fix https://github.com/rtfeldman/roc/pull/1802

view this post on Zulip Folkert de Vries (Nov 01 2021 at 10:59):

I probably have that branch locally, I pulled basically right before this happened. What do I do? just a git push?

view this post on Zulip Brian Hicks (Nov 01 2021 at 11:06):

a git push -u origin HEAD from that particular branch would be the most sure-fire way

view this post on Zulip Folkert de Vries (Nov 01 2021 at 11:10):

ok, did that

view this post on Zulip Brian Hicks (Nov 01 2021 at 11:15):

ok, I think that's the last of the closed PRs.

view this post on Zulip Brian Hicks (Nov 01 2021 at 11:16):

looks like we're still ~45 builds deep in the queue so waiting to push more would be good

view this post on Zulip Brian Hicks (Nov 01 2021 at 11:16):

unless there's any of these workflows we can just cancel? I know it's gonna take a bite out of the quota https://github.com/rtfeldman/roc/actions

view this post on Zulip Folkert de Vries (Nov 01 2021 at 11:17):

there are some that I'm pretty sure will fail

view this post on Zulip Anton (Nov 01 2021 at 11:18):

We're all self-hosted, I'll close some that I know can be closed.

view this post on Zulip Brian Hicks (Nov 01 2021 at 11:29):

oh! I didn’t know we were completely self-hosted. I thought it was just benchmarks!

view this post on Zulip Anton (Nov 01 2021 at 11:44):

I've made issue #1868 to see what steps can be taken to prevent this in the future as well as how we can setup a workflow to restore things quickly in case things do go wrong.

view this post on Zulip Locria Cyber (Nov 01 2021 at 13:21):

Folkert de Vries said:

I probably have that branch locally, I pulled basically right before this happened. What do I do? just a git push?

git reflog show will show the past change of branch/HEAD point to which commits

view this post on Zulip Locria Cyber (Nov 01 2021 at 13:22):

Then you can do git merge <commit hash> from a branch

view this post on Zulip Folkert de Vries (Nov 01 2021 at 13:23):

I got it that branch should be good now

view this post on Zulip Lucas Rosa (Nov 01 2021 at 14:06):

oh ok, I was like wth happened lol


Last updated: Jul 06 2025 at 12:14 UTC