Git is the free and open-source distributed version control system that’s responsible for everything GitHub related that happens locally on your computer.
Inspect & Compare
Examining logs, diffs, and object information
Show the commit history for the currently active branch
git log
Show the commits on branchA that are not on branchB
git log branchB..branchA
Show the commits that changed file, even across renames
git log –follow [file]
Show the diff of what is in branchA that is not in branchB
git diff branchB…branchA
Show any object in Git in human-readable format
git show [SHA]
Tracking Path Changes
Versioning file removes and path changes
Delete the file from the project and stage the removal for the commit
git rm [file]
Change an existing file path and stage the move
git mv [existing-path] [new path]
Show all commit logs with an indication of any paths that moved
git log –stat -M
Ignoring Patterns
Preventing unintentional staging or committing of files
Save a file with desired patterns as .gitignore with either direct string matches or wildcard globs.
logs/
*.notes
pattern*/
System-wide ignore pattern for all local repositories
git config –global core.excludesfiles [file]
Share & Update
Retrieving updates from another repository and updating local repos
Add a git URL as an alias
git remotes add [alias] [url]
Fetch down all the branches from that Git remote
git fetch [alias]
Merge a remote branch into your current branch to bring it up to date
git merge [alias]/[branch]
Transmit local branch commits to the remote repository branch
git push [alias] [branch]
Fetch and merge any commits from the tracking remote branch
git pull
Rewrite History
Rewriting branches, updating commits, and clearing history
Apply any commits of the current branch ahead of the specified one
git rebase [branch]
Clear staging area, rewrite working tree from the specified commit
git reset — hard [commit]
Temporary Commits
Temporarily store modified, tracked files in order to change branches
Save modified and staged changes git stash
List stack-order of stashed file
changesgit stash list
Write working from the top of the stash
stackgit stash pop
Discard the changes from the top of the stash
stackgit stash drop
Thank you for reading this article, I really appreciate it. If you have any questions, feel free to leave a comment.