Featured post
repository - How can I undo my last git add/commit? -
i edited file , did:
git add file.py git commit -m 'fixed bug'
i edited file , performed minor bug fix. don't want 2 commits, 1 after other, showing 'bug fix'. want 1 commit 'bug fixes'.
how can undo last add/commit , change first commit message?
i looking @ git reset
, git revert
, git undo
commands don't want screw repo guess
edit: found out how it: http://www.gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
if commited second change, reset first:
git reset head^
now head
@ first commit, , content of local files unchanged.
git add <the file(s) second bug fix> git commit --amend -m'bug fixes'
if tracked , changed file included second bug fix, can run instead, usual:
git commit -a --amend
amending commit this:
- adds changes in index previous commit (therefore need
git add
, or-a
) - allows change commit message
be careful, though: if have distributed first commit, other people's repo strange. should not change commit else has fetched.
you use git merge --squash
, feels more logical not easier. use merge branch containing 2 commits, unto previous commit.
squashing works git rebase
well.
- Get link
- X
- Other Apps
Comments
Post a Comment