본문 바로가기

Git

Remove/Change Previous Commit

* When trying to delete any of the previous commit,

If aaa is the hash to remove,

1. > git rebase -i aaa^

2. Remove that commit(aaa)

3. If there is a conflict, (if not continue..)

==> resolve conflict

     > git add .

     > git rebase --continue

4. > git push -f origin my-branch-name


* When trying to undo pushed commit,

1. > git log and get the hash(aaa) to revert to

2. > git push -f origin aaa:my-branch-name

If you want to undo all local changes,

> git reset --hard aaa

If you keep your local changes,

> git reset --soft aaa


* When trying to change the latest commit message after the push

On your branch,

1. > git commit --amend

2. Change the commit message

3. > git push --force origin my-branch-name

'Git' 카테고리의 다른 글

Rebase My Branch on Top of Something  (0) 2018.11.08
Undoing Changes  (0) 2017.06.18
How to view the commit log  (0) 2017.06.11
Performing first commit  (0) 2017.06.11
Initializing a repository  (0) 2017.06.11