TODO: This needs to be reviewed and updated for the latest uses I do
How to check which gitignore rule is ignoring the file
git check-ignore --verbose <PATH>
Quick cheat sheet for the most common and forgettable things.
Config
Staging, Commit and Status
Log : commit history
Amend
Normally done if you forgot to stage a file, or to change the commit message.
If you want to stage more file than you have committed previously, just stage
that files first than use this command and this will stage
the file you forgot as well.
Unstage a file
When you want to unstage a file that you have staged.
Branching
Rebasing
Rebasing moves a branch to a new ( master / base ) commit.
This is also referred to as a fast forward merge.
Revert and Reset
Some times you want to eliminate a previous commit,
but you still want to keep the commit for integrity reasons.
Revert is usefull in this case.
Reset eliminates previous commits and you can never get them back.
You really should never use it actually.
Clean
Clean removes untracked files from your directory and is undoable.
Credential helper
Sometimes it is very tedious to enter Username and Password for same repository repeatedly.
Here is a solution to that!
Misc
Suppose you are on the master branch and you would like to test if the dev branch can be merged without conflict into the master.
After that, you will be able to know if there’s a conflict or not.
To return in a normal situation, just abort the merge:
Check a pull request locally
# Fetch the PR from the remote repository
git fetch origin pull/<PR-number>/head:<local-branch-name>
# Checkout the PR branch locally
git checkout <local-branch-name>
Make sure to replace <PR-number> with the actual pull request number and
<local-branch-name> with a descriptive name for the branch you’ll check out
locally.