Can I append 2 git commits after i push
Is it possible for me to 'git commit --amend' 2 commits AFTER I have pushed?
git commit
git push
git commit
git push
Can I some how co开发者_如何学运维mbine the 2 commits that I did?
Thank you.
The answer to this depends on whether it's OK for you to "force push" to your repository - in other words to push a commit that doesn't contain the remote branch as part of its history. For example, it's certainly OK for you to force push if one of the following applies:
- If it's just you using the repository
- If you know no one will have pulled your changes
- If you can tell your collaborators that you've pushed a rewritten master branch (and they'll know what to do about that!)
If so, then you could go ahead and do the following:
# Reset the master branch pointer to the commit before, but leave the index
# and your working tree as is:
git reset --soft HEAD^
# Amend the commit you're now at with the current index:
git commit --amend
# Push the master branch with '-f' for '--force':
git push -f master
I believe you mean "amend", not "append". In any case, while it's certainly possible to do anything you want, it's a rather bad idea to go modifying history (which amend does) once you've pushed.
精彩评论