Squashing or editing some commits before doing git-svn dcommit?

后端 未结 4 584
梦如初夏
梦如初夏 2021-02-09 06:49

I am working on a project in a subversion repository with a strict check-in policy which includes: Every commit to the trunk has to be reviewed by another developer and this mus

4条回答
  •  死守一世寂寞
    2021-02-09 06:57

    You can interactively rebase your local branch against the Subversion tracking branch which provides you with an opportunity to squash and amend the commit.

    Next time you dcommit, dcommit will replay your history one commit at a time and this is what will be commited to Subversion.

    Assumptions:

    1. Local branch is master
    2. Master is checked out
    3. Remote tracking branch is named git-svn
    4. git-svn is up to date

    What to do:

    $ git rebase -i git-svn
    

    Your default editor will open with a list of commits in master to rebase against git-svn. You can pick, edit or squash the commit (Mix and match if desired).

    After making your selection, another temporary file will open displaying commit messages for each of the commits you're rewriting. This is where you amend the commit message.

    Caveats:

    You're rewriting the history of your repository, exercise caution. It might be worthwhile experimenting with this behaviour until feel confident.

提交回复
热议问题