git statusgit log--stat: log with the change stats.
git branch: shows all available branches.<branch_name>: creates a branch with name as<branch_name>.
git ammend--amend -m“change the commit message” : changes commit message only--amend <nothing>: recommits with interactive editor for changing message.
git checkout<branch_name>: switches to<branch_name><file_name>: removes all recent changes for<file_name><commit_hash>: pulls the commit with hash<commit_hash>in a “DETACHED HEAD” state. i.e. We are not on any branch but outside. aNy changes will be discarded in not made permanent. If changes are to made permanent, create a new branch.
git diff<commit_hash_1> <commit_hash_2>: compares difference between commits with hashes<commit_hash_1>and<commit_hash_2>.
git cherry-pick <commit_hash>- applies changes from
<commit_hash>to the current branch.
- applies changes from
git reset--soft <commit_hash>: return to commit with hash<commit_hash>with changes still in staging area.<commit_hash>: return to commit with hash<commit_hash>with changes in working directory and not staged.--hard <commit_hash>: return to commit with hash<commit_hash>with all the modifications deleted. Untracked files are left alone… for getting rid of untracked files seegit clean.
git clean-df: removes untracked files(-f) and directories(-d).
git reflog: shows all the log where a commit is referenced.git revert<commit_hash>: undos the changes from commit with hash<commit_hash>. keeps git history clean.
git fetch<remote_name/branch_name>: brings all changes from the remote repo to the local repo, but doesn’t merge with existing files.
git merge<remote_name/branch_name>: Merging combines your local changes with changes made by others.
git pull: A convenient shortcut forgit fetchandgit merge<remote_name/branch_name>: fetches all changes from the remote_repo<remote_name>to the local repo and merges the changes.
If any merge conflicts, then do
git merge --abortto take the branch to where it was before you pulled.