开发者

Rebase, but ignoring one upstream commit?

开发者 https://www.devze.com 2023-02-20 15:09 出处:网络
I\'m trying out git for local workflow management, with an eye toward proposing it for my team. So I\'d like to fully get my head around it, and I\'m coming up against something I don\'t understand.

I'm trying out git for local workflow management, with an eye toward proposing it for my team. So I'd like to fully get my head around it, and I'm coming up against something I don't understand.

Where I came into git-land was, I had a SVN repository that has me and one other developer working on it. Our PM changed the project timeline such that his sub-project needs to go to production almost immediately, followed by mine in about a month. We're both developing in the same SVN repo, and my stuff is already starting to be visible to the user, and so needs to be backed out for the upcoming production migration.

I updated my SVN working directory. I initied a git repository in that same directory (ignoring .svn, etc). I did git branch map-dev to create a development branch for my (map-related) sub-project. I did git checkout master to get back to the SVN-synced branch, and edited those files to take out my work. Once the early parts of my project were no longer visible, I committed to git (with the comment "map search stuff rendered invisible"), committed to SVN, and pushed the SVN content to staging. So now what's up on the staging/test server has none of my stuff and all of his, and that's fine.

A few days later, I've developed along in my map-dev branch, and my colleague has checked in some stuff to SVN that doesn't REALLY impact what I'm doing, but I'd like to stay in sync with.

I git checkout master. I svn up. I git commit -a with the comment "update from SVN".

Now I think, okay, rebas开发者_开发百科e map-dev with those changes in master, right? So I do that, I resolve a conflict or two, and everything seems hunky-dory. Then I notice that the changes I committed on master called "map search stuff rendered invisible" are what's current. There ISN'T a more recent commit on my dev branch, it was just how that stuff was when the repo was first committed.

So. I used git revert --hard ORIG_HEAD to get back to where I was before the rebase. What I want is the CSV changes I just put in master but NOT the commit that made my work invisible. How should I do that?


I would suggest merging his code into your dev branch:

git checkout map_dev
git merge master

Then revert your commit that removed your code:

git revert <sha1>

Where is the SHA1 of the commit that removed your code from master. Now you'll have his code in your map_dev branch, minus your cleanup. It'll make merging your code back into master easier, when you get there.

Edit: Alternatively, it may be easier (resulting in a cleaner merge) if you do something more like this:

git checkout master -b temp
git revert <sha1 of code removal>
git checkout map_dev
git merge temp
git branch -d temp

This will put the revert of the code removal at the top of your branch, which may cause fewer merge conflicts. I can't say for certain.

0

精彩评论

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