Takeout: git - ramirezfranciscof/aiida-core GitHub Wiki
To check differences you can use the following set of commands. You can replace the [commit] placeholders with the SHA of the commit, with the name of a branch, or with a reference to the current position (HEAD, HEAD~1, etc). The order in which you provide the commits determines who uses '---' and '+++' (plus something else in the last command), so I advise to think of the first commit as the base and the second commit as the modifications.
# Two points show difference in all files between two commits
git diff [commit_a]..[commit_b]
# Better to add option to see only files changed
git diff --name-only [commit_a]..[commit_b]
# And then you can check each file
git diff [commit_a]..[commit_b] -- main.c
# Finally, if you need to be super-specific
git diff [commit_a]:[path/to/file_a] [commit_b]:[path/to/file_b]
# Difference between commit_b and common ancestor of both (order here matters the most)
git diff [commit_a]...[commit_b]
You first load (checkout) the commit/branch where you want to work, and once there you load (checkout) just the single file you need from your source commit/branch.
git checkout [commit_target]
git checkout [commit_source] -- [file_name]
This allows you to go back to a previous commit but keep the working directory as it currently is in the up-to-date commit (useful to re-organize in commits a series of disorganizedly commited work):
git reset [TARGET_COMMIT_HASH]
So git reset without a --hard or --soft moves your HEAD to point to the specified commit, without changing any files.
Then you can start adding the files you want to the new next commit, and if you only want to add PART of a file, you can:
git add --patch <filename>
#OPTIONS:
# y stage this hunk for the next commit
# n do not stage this hunk for the next commit
# q quit; do not stage this hunk or any of the remaining hunks
# a stage this hunk and all later hunks in the file
# d do not stage this hunk or any of the later hunks in the file
# g select a hunk to go to
# / search for a hunk matching the given regex
# j leave this hunk undecided, see next undecided hunk
# J leave this hunk undecided, see next hunk
# k leave this hunk undecided, see previous undecided hunk
# K leave this hunk undecided, see previous hunk
# s split the current hunk into smaller hunks
# e manually edit the current hunk
# ? print hunk help
git fetch remote pull/<ID>/head:<local_branch_name>
Just show tagged logs (The --no-walk prevents this from starting with tags and finding all their parent commits, and the parents' parents, and so on.):
git log --no-walk --tags