Useful GIT command scroll

Git Commands
Initialize a local Git repository git init
Check status git status
Add a file to the staging area git add [file-name.txt]
Commit changes git commit -m “[commit message]”
View changes git log
View changes (detailed) git log –summary
Add a remote repository git remote add origin[repository-name].git
Set a repository’s origin branch to SSH git remote set-url origin ssh://[repository-name].git
Push changes to remote repository (first time) git push -u origin master
Push changes to remote repository (subsequent times) git push
Pull changes from remote repository git pull origin master
Create a local copy of a remote repository git clone ssh://[repository-name].git

All-purpose git command line to include directly to your alias list


Show git branches by date – useful for showing active branches
Print out list of all branches with last commit date to the branch, including relative time since commit and color coding


Add forgotten changes to the last git commit
It’s pretty common to forgot to commit a files, be it a modification, or a brand new file.


Show ALL branches

for k in git branch -r|awk '{print $1}';do echo -e git show --pretty=format:"%Cgreen%ci_%C(blue)%c r_%Cred%cn_%Creset" $k|head -n 1$k;done|sort -r|awk -F”_” ‘{printf(“%s %17s %-22s %s\n”,$1,$2,$3,$4)}’

Get all git commits of a specific author in a nice format

git log –name-status –author=”[The Author’s Name]”

List all authors of a particular git project


Matrix Style


show git commit history


Add .gitignore files to all empty directories recursively from your current directory

Figures out what has changed in the last 12 hours

enable color git

git config –global –add color.ui true

Git Tree Command with color and tag/branch, add this to ~/.gitconfig

list of commits (simile gitk)

git pull all repos

Show git branches by date – useful for showing active branches

Open the current project on Github

ignore .DS_Store forever in GIT

echo .DS_Store >> ~/.gitignore

git remove files which have been deleted

git add -u

Show GIT stats

git log –stat

diff’s on files

git diff –color-words file1 file2

Show git branches by date – useful for showing active branches

git for-each-ref –sort=-committerdate –format=”%1B[32m%(committerdate:iso8601) %1B[34m%(committerdate:relative) %1B[0;m%(refname:short)” refs/heads/

Number of commits per day in a git repository

git log | grep Date | awk ‘{print ” : “$4” “$3” “$6}’ | uniq -c

remove .DS_Store from repo

A nice way to show git commit history, with easy to read revision numbers instead of the default hash

Further more:

If you have a really cool one, please add it!
Plattform Test: Tested PASSED: on Snow Leopard
Git Version: git version

Leave a Reply

Your email address will not be published. Required fields are marked *

* Copy This Password *

* Type Or Paste Password Here *