简体   繁体   中英

Git move commit to different local repository

I have two local git repositories, both cloned from different svn repositories:

  1. git-6.1-pa (latest svn branch)
  2. git-6.0-pa (stable svn branch, different source code tree, but similar to 6.1)

Currently, I have in git-6.1-pa reviewed and committed to svn repository revision (by git svn dcommit) - e27cf8edb2f69daf054aa6bb379d668e4b3d52f0 with own git-svn-id.

What I want - to move this commit to another local git-6.0-pa repository.

I tried this answer and it works great, but... I got:

1. Successfully applied commit.
2. This commit is not on top of history (3rd)
3. Contains unnecessary old git-svn-id, because I'm going to call git svn dcommit on this moved commit.

and I want to get:

1. Successfully applied commit (or diff suitable to commit).
2. Commit is on top of history (or diff suitable to commit)
3. Doesn't contain old git-svn-id, that I can just call git svn dcommit

Is this possible?

Your item 3), old git-svn id is not a problem. It will be ignored and overridden when you do git svn dcommit . If you are concerned about it - do git commit --amend or git rebase -i with r option to amend the comment.

Your issue 2) is not very clear to me. If you don't like the order in which your commit it cherry-picked, you can change it with the help of git rebase interactive ( git rebase -i <some sha earlier> ), but you should not do that with the commits that are coming from your linked svn. I am still surprised how did you get your commit "not on the top of the history". Normally if you do a cherry-pick, the new commit will be added on top of your HEAD. Did you working copy point to the "top of the history" before you did the cherry-pick?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM