Tuesday, June 16, 2009

Screwing up git

Egads. I just deleted my branch without pushing the changes. At first I thought that I might have lost a couple of days of work. But then I found this article. The first comment is particularly helpful. The docs about git log are also helpful.

Basically, what I did from this point was do a "git log -g", which allowed me to look through all of refs, whether they had associated branches or not. Next, I merged these back in one by one by their sha hashes using "git cherry-pick . Ideally, I might have done this in a new branch instead of master, but I didn't think ahead. Also, there may have been a better way to do it than going cherry-pick by cherry-pick, but there were only 10 or so, and merging smaller pieces worked out well.

Anyways, if I lose my changes like that again, my workflow will be something like this:

git log -g
git checkout -b new_branch_to_apply_cherry-pick_to
git cherry-pick (until done, merging/committing stuff as necessary)
git push wherever
git checkout master
git pull wherever
git branch -D new_branch_to_apply_cherry-pick_to (after making damn sure things are in order)

No comments:

Post a Comment