## Global Configuration
# Enable color console git config --global color.ui auto # Set meld as the diff tool git config --global diff.tool meld
# Convert a non-bare repository into a bare one git config --bool core.bare true
# To edit last commit log (and possibly change # the author data if it was changed) git commit --amend --reset-author
MYDATE='1999-12-31T23:59:59' GIT_AUTHOR_DATE=$MYDATE GIT_COMMITTER_DATE=$MYDATE git commit -m 'bla bla bla''
git reset --hard HEAD~1
git push --force
# Remove untracked files and directories (not ignored) git clean -f -d # Remove untracked files and directories including ignored ones) git clean -f -x # Remove ignored files git clean -f -X
git add # Stage a file git add --all # Also stage deleted files # Changed or new not ignored. Deleted files not staged git add . # Stage currently tracked files (Not adding files ) git add -u # Equivalent to all above git add -A # Unstage a file git reset HEAD
git rm --cached # Remove from git database but not from the filesystem
git checkout -- src/com/mmonem/erp/server/service/LoginServiceImpl.java
git checkout . -f
# List all branches: git branch -a # List remote branches: git branch -r # Switch to a branche git checkout TheBranche # Switched to a new branch git checkout -b NEW_BRANCHE_NAME # Or: git branch NEW_BRANCHE_NAME git checkout NEW_BRANCHE_NAME # Delete a branch git branch -d BRANCHE_NAME
git remote -v git remote show origin
git remote add
git remote set-url origin
git branch --set-upstream-to=origin/master
git push --all -u git push --tags git push git push :
git push origin --delete
or
git push origin :
git push origin origin/:refs/heads/
git push origin :old new
git fetch [remote] -p
git ls-files git ls-files -m # List modified files only git branch -a
# All branches, all history git clone [local_dir] # Specific branche git clone -b # Not all history git clone --depth 1 # Into another bare repo git clone --bare . /other/dir/name.git
# Enable sparse configuration git config core.sparsecheckout true # Set what do you want to track echo some/dir/ >> .git/info/sparse-checkout echo another/dir >> .git/info/sparse-checkout # And finally git read-tree -mu HEAD