How to view diff for things to be committed (after git add
invocation), that is, “staged”:
$ git diff --cached
How to look at specific file’s contents at some stage (HEAD~4
is “some stage”):
$ git show HEAD~4:somedir/somefile
How to change specific commit (feed5e
):
$ git rebase feed5e^ --interactive
This command will fire up editor: modify, replace pick
with edit
for that commit, save, and close editor. Then do necessary changes (for instance, git add somefile
) and do usual git commit --amend
. To finish, use git rebase --continue
. So:
Start rebase:
$ git rebase feed5e^ --interactive
Set ”edit” for commits you want to change.
Do changes to files.
Commit changes:
$ git commit --amend
Continue the rebase:
$ git rebase --continue
This blog is about things I encounter while doing web and non-web software development.