使用git rebase -i

时间:2013-01-02 20:53:33

标签: git version-control

所以我试图使用http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html

中的说明拆分提交

尝试搜索“SPLITTING COMMITS”

它说“用行动标记要分割的提交”编辑“。”

我到底该怎么做

当我执行git rebase -i时,它会打开一个文件

# Commands:
#  p, pick = use commit
#  r, reword = use commit, but edit the commit message
#  e, edit = use commit, but stop for amending
#  s, squash = use commit, but meld into previous commit
#  f, fixup = like "squash", but discard this commit's log message
#  x, exec = run command (the rest of the line) using shell
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

...

我究竟如何从该对话框执行这些命令

修改

所以我成功地成功改装并致力于我当地的回购......

问题是,当我尝试推送时,我收到错误消息:

 ! [rejected]        JJ-4322 -> JJ-4322 (non-fast-forward)
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'url.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

任何想法?

1 个答案:

答案 0 :(得分:0)

rebase -i COMMIT

将向您显示提交列表,您可以使用该列表中的任何内容更改默认选择命令

pick 6d6da13 0000, liquibase, fixing build snafu's

# Rebase c56baf2..6d6da13 onto c56baf2

变为

edit 6d6da13 0000, liquibase, fixing build snafu's

# Rebase c56baf2..6d6da13 onto c56baf2

编辑:

您的第二个问题是因为您正在重写历史记录,并且您已经推送了现在与您当前状态冲突的旧版本。你需要这样做:

git push --force YOURBRANCH

这将覆盖遥控器上的内容。