This is a list of useful commands for git for fast search and ops developers, enjoy and comments for suggest all welcomes :D
Public repo .tar for download versions: https://www.kernel.org/pub/software/scm/git/
Delete with git all files listed as deleted:
$ git rm $(git ls-files --deleted)
Delete a branch DOWN in the local repository:
$ git branch [branch name] --delete
Delete a branch UP in the services repository:
$ git push origin --delete [branch name]
Do not track changes on specific file:
$ git update-index --assume-unchanged [file]
Track changes again:
$ git update-index --no-assume-unchanged
List hidden tracked files:
$ git ls-files -v | grep '^[[:lower:]]'
Cleaning up cache when git ignore fail (options):
$ git rm -r --cached .
$ git add .
$ git commit -m "Fixed untracked files"
Clone a repo specifying the branch:
$ git clone -b <branch> <myproject>.git
Ignore mode file change, setting up git:
$ git config core.fileMode false
git checkout, doesn't work... possibilities:
$ git config --global core.autocrlf false
$ vim .gitattributes # comment line "* text=auto"
Setting up git color:
$ git config --global color.ui true
Rolling back a commit:
$ git reset --soft 'HEAD^'
Discard last commit:
$ git reset HEAD --hard
$ git reset --hard origin/master
$ git reset --soft HEAD~1
Merging conflicts (accept theirs):
$ git checkout --theirs
Merging conflicts (accept ours):
$ git checkout --ours
Remove a remote:
$ git remote rm <remote>
Resolve problem with CRLF sequence:
$ git diff --ignore-space-at-eol
Add just tracked files to the stage:
$ git add -u .
Revert changes on a specifuc file commited and begin again:
$ git checkout commit-reff~1 -- <file name>
Remove the last commit and set the change to "Changed but not updated":
$ git reset HEAD~1
Export a "clean" project:
$ git archive master | tar -x -C </somewhere/else>
$ git archive master | bzip2 > <source.tar.bz2>
$ git archive --format zip --output <zipfile.zip> master
Note: This is a synonym to svn export. What this does is export and compress a repository without any .git* files.
Removing file from all history: https://help.github.com/articles/remove-sensitive-data/
Setting global ignore
$ git config --global core.excludesfile ~/.gitignore_global
Pretty git log
$ git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
Alias git lg:
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Turn off the warning CRLF
git config core.safecrlf false
Change domain to clone (bower)
$ git config --global url."https://".insteadOf git://
Publish to github pages
$ git subtree push --prefix <my site folder> origin gh-pages
Exporting a "clean" project
This is a synonym to svn export. What this does is export and compress a repository without any .git* files.
tar
git archive master | tar -x -C /somewhere/else
bzip2
git archive master | bzip2 >source-tree.tar.bz2
zip
git archive --format zip --output /full/path/to/zipfile.zip master