What should I do after a change is abandoned?

3,258 views
Skip to first unread message

Paul Holmes

unread,
Apr 20, 2014, 2:28:06 PM4/20/14
to repo-d...@googlegroups.com
This is a double-noob question, as I am new both to Gerrit and to Git.

I made four changes to a project, committed them to my local repo, then pushed them to /refs/for/master for Gerrit review.
Three of the changes (lets call them 1, 3 and 4) were accepted.
One of them (call it 2) was abandoned, and with good reason.
I understand that there are ways I could amend and/or restore it, but in this case I don't want to do that - I want to forget about 2 and move on.

Here's the problem: Although the master (quite rightly) contains only changes 1, 3 and 4, my local repo still contains change 2 as well - which I no longer want. I know that in principle, what I need to do is to get my local repo back in sync with the master, but because I'm so new to the whole toolchain, I don't know what sequence of commands I should carry out to achieve this.

Can anyone suggest a step-by-step approach to get me back on track?


David Pursehouse

unread,
Apr 20, 2014, 8:07:14 PM4/20/14
to Paul Holmes, repo-d...@googlegroups.com
Assuming 1, 3 and 4 have been merged:

The following commands will update your local repository with changes
from the Gerrit server, and then reset your local branch to the head of
the master branch.

$ git fetch
$ git reset --hard origin/master

Or if 3 and 4 are still under review, blocked by 2:

$ git fetch
$ git rebase -i origin/master

This will start an interactive rebase. The default editor will open
with a list of commits to be rebased. Remove commit #2 from the list of
commits, save, and exit the editor. If there are conflicts you will
need to resolve them, add the resolved files with `git add` and then
`git rebase --continue`.

Paul Holmes

unread,
Apr 21, 2014, 3:39:35 AM4/21/14
to repo-d...@googlegroups.com
Hi David,
Thanks for the tip. I'll give it a try.
Paul.

Yanis Guenane

unread,
Apr 21, 2014, 4:28:40 PM4/21/14
to Paul Holmes, repo-d...@googlegroups.com
Also, to avoid those kind of situation you should do your changes in a separate branch.

So the workflow would be as follow :

$ git clone ....
$ git checkout -b mybranch
<commit>
$ git review

This way your master remains always clean (vanilla branch), all you'll have to do is update it before any new change and create a new branch out of it.

Hope it helps,



--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Yanis Guenane

Paul Holmes

unread,
Apr 22, 2014, 3:47:25 AM4/22/14
to repo-d...@googlegroups.com
Thanks Yanis.
I'll try that next time.
P.
Reply all
Reply to author
Forward
0 new messages