git rebase:“无法应用(哈希)。”我迷路了

时间:2014-06-06 07:38:26

标签: git github pull-request squash

我被要求“改变并压缩(我的)提交到一次提交?”拉取请求https://github.com/samtools/htsjdk/pull/34#issuecomment-45226559

这是我第一次这样做,我认为我只会做错事。我现在迷路了。

上次我尝试了一些事情:

$ git branch
* fastq
$ git status
$ git merge-base fastq master 
67901f963470a1cd2f8477f736b6b2192343485c
$ git rebase --interactive 67901f963470a1cd2f8477f736b6b2192343485c

(... tried things, ... pulled, pushed, etc...)

$ git rebase --continue
error: Ref refs/heads/fastq is at a3aa885e4943279a7ece9e2eae85b1a80c41af32 but expected c5dc7c69108d1d72cf9eeb0144332075b06fea71
fatal: Cannot lock the ref 'refs/heads/fastq'.

应该怎样做才能回答评论者的需求?

更新:当我尝试推送时

$ git push origin fastq
To https://github.com/lindenb/htsjdk.git
 ! [rejected]        fastq -> fastq (non-fast-forward)
error: failed to push some refs to 'https://github.com/lindenb/htsjdk.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

1 个答案:

答案 0 :(得分:4)

关于your fasq branch中的变基,那将是:

git checkout fastq
git rebase -i 67901f963470a1cd2f8477f736b6b2192343485c (last commmit before your change)

# select s for each commmit in order to squash them)

由于历史记录不同,您必须在提交变基/压缩后强行推送您的分支。

git checkout fastq
git push -f

这将自动更新PR(拉动请求)。