Command | Notes |
---|---|
git diff |
Shows the difference between your working tree(your current changes) and the HEAD of your repo |
git diff --cached |
Shows the difference between the index tree(the changes that you've already staged) and the HEAD |
git diff --color-words |
Format the differences so that it doesn't duplicate changed lines(before/after), and instead uses colors on the same line to highlight what has changed |
git diff 2154af2 7d6a9b4 |
Show differences between 2 commits. |
git diff branch_1..branch_2 --name-status |
Compare 2 branches and output the list of files that are different |
git diff c45702c your-file |
Difference in a file from working directory and a specific commit. |
git diff head |
Shows the difference between all your changes(total changes of the working and index trees) and the HEAD |
git diff head~3..head your-file |
Difference in a file from 3 commits ago |
Command | Notes |
---|---|
git tag | List all existing tags for the current checked-out branch |
git tag --delete tagname | Delete tag locally |
git tag -a v.1.2.2 -m "hello world" | Add tag and a message on the head of the current checked-out branch |
git tag -a v.1.2.2 -m "hello world" 12frt5 | Add tag and a message on a specific commit |
git tag -d your-tag-name | Delete tag |
git tag -l "v.1.2.*" | Filter tags using regex for the current checked-our branch |
git tag -n | List tags WITH messages |
GitHub can only manage files as big as 50MB. Over that limit, you must use git-lfs
.
- Official link: https://git-lfs.github.com/
- To test whether it is already installed:
which git-lfs
brew install git-lfs
To set it up for you user account:
git lfs install
To test it is installed:
which git-lfs
git lfs track "*.psd" & \
git add .gitattributes
Error in git-raw-commits: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree
Execute this command:
git commit --allow-empty -n -m "Initial commit."
[alias]
co = checkout
st = status
b = branch
cp = cherry-pick
a = add --all
cm = commit -am
pullo = pull origin
pusho = push origin
mt = mergetool -t kdiff3
unstage = reset head
rb = pull --rebase origin
l = log --oneline
pushm = push origin master
pushs = push origin staging
pusht = push origin test
pushd = push origin dev
pulls = pull origin staging
pullm = pull origin master
pullt = pull origin test
pulld = pull origin dev
cos = checkout staging
com = checkout master
cot = checkout test
cod = checkout dev
notpushed = "!f() { git log origin/$1..$1; }; f"
keepMine = "!f() { git checkout --ours $1; git add $1; }; f"
keepTheirs = "!f() { git checkout --theirs $1; git add $1; }; f"
pr = "!f() { git checkout -b $1-master master; if [ ! -z "$3" ]; then git pull https://github.com/$1/$2.git $3; else git pull https://github.com/$1/$2.git master; fi }; f"
doc = "!f() { \
echo 'a - git add --all [Add all current changed from the working dir to the staging tree]'; \
echo 'b - git branch [List all branches]'; \
echo 'cm - git commit -am [Commit all changes to the head]'; \
echo 'co - git checkout [Change to another branch]'; \
echo 'com - git checkout master [Change to the master branch]'; \
echo 'cos - git checkout staging [Change to the staging branch]'; \
echo 'cot - git checkout staging [Change to the test branch]'; \
echo 'cp - git cherry-pick [Cherry pick]'; \
echo 'l - git log --oneline [List latest logs]'; \
echo 'keepMine <filePath> - Resolve conflict by keeping my file'; \
echo 'keepTheirs <filePath> - Resolve conflict by keeping their file'; \
echo 'mt - git mergetool -t kdiff3 [Open the merge tool]'; \
echo 'notpushed <commit hash> - Check if a commit has been pushed to the origin or not'; \
echo 'pr <github requester username> <project name> [requester branch] - Get the pull request from requester. Default branch is master'; \
echo 'pullm - git pull origin master [Pull latest changes from origin master]'; \
echo 'pullo - git pull origin [Pull latest changes from origin for all installed branches]'; \
echo 'pulls - git pull origin staging [Pull latest changes from origin staging]'; \
echo 'pullt - git pull origin test [Pull latest changes from origin test]'; \
echo 'pushm - git push origin master [Push current head to origin master]'; \
echo 'pusho - git push origin [Push current the head of all your installed branches to origin]'; \
echo 'pushs - git push origin staging [Push current head to origin staging]'; \
echo 'pusht - git push origin test [Push current head to origin test]'; \
echo 'st - git status [Show the status of your current branch]'; \
echo 'unstage - git reset head [Move changes from head to the working dir. Usefull to stash]'; \
}; f"
[color]
ui = auto