Thursday, June 16, 2016


always safe : git checkout -b new_branch

git reset --cached
git rm --cached
git reset -- tracking.txt
git rm
git mv

git add -A
git add -a
git add -u

git add --update
git add --all

git init
git clone
git --version


git clone --bare
git log --abbrev-commit --abbrev=4 --pretty=oneline -10
git log --author="John Resig"
git log --pretty=oneline --since="2012-12-20" --until="2013-01-01" -5
git log --pretty=format:"%an --- %H"
Joe Doe --- 123456...

git log --pretty=oneline | wc -l
 git shortlog -s | wc -l

git log --pretty=format:%cd --date=short | uniq | wc -l

 du -h -s .git
du -h -s --exclude=.git

git alias

git stat
git info

git shortlog -n -s

    bare = true

git status -s -b

username different for every repo
global vs local config

git init

git reflog
git reset --hard HEAD@{1}
git chekcout -b new_branch

git reflog expire --all --expire=now
git prune --dry-run

2 status

git rm
git mv
git rm --cached
git log --oneline --graph --decorate --all
git show info^{tree}
git show SHA-1^{tree}
git branch -v -> latest revision in every branch
git pack-refs --all
git internal files
cat .git/refs/heads/new_one
cat .git/HEAD
cat .git/packed-refs

git branch -vv
git remote -v
ordinary local branches
local tracking
remote tracking
different pull push urls
git branch -a
git branch -r

create branch : git branch doc
switch branch : git checkout doc
show branches : git branch
git checkout -b new-branch existing-branch
git checkout -b new-branch HEAD
Show all branches : 
git branch -a -vv
git branch -r : remote
Ordinary local branches 
Local tracking branches 
Remote tracking branches 
git remote rm origin
list-remote-branches = "!listRemoteBranches() {
    git branch -r | sed \"/->/d; s/  origin\\///g\";
}; listRemoteBranches"
checkout-remote-branches = "!checkoutRemoteBranches() {
    for name in `git list-remote-branches`; do
        git checkout $name;
}; checkoutRemoteBranches"

clone-with-branches = "!cloneWithBranches() {
    git clone $1 $2;
    cd $2;
    git checkout-remote-branches;
    git remote rm origin
}; cloneWithBranches"
git remote -v
For untracked filed : 
git clean -f
git clean -n
git pack-refs
git cherry-pick <rev> -> creates a new rev
git branch -d
git branch -D
git branch --merged
git branch --no-merged
branch rename
git branch -m info information
git branch -M info information
checkout file from a different revision/branch
git checkout info -- i1.txt
git show doc:m1.txt
git clone won't preserve reflog, cp will
 git merge --ff-only feature : merge only if fast forward case
git log --oneline --merges : show only merge commits
git log --oneline --no-merges : show only no merge commits
git log --oneline --max-parents=X --min-parents=Y
 git merge --no-ff feature : force creation of merge commit even if fast forward is possible
git log --oneline --graph --all
git merge a b c d
git rebase
git rev-parse master
git checkout `git rev-parse master` : to enter detached HEAD
rebase alternative : git checkout `git rev-parse master`; git am *.patch; git checkout -B feature 
rebase can also be done with cherry-pick

No comments:

Blog Archive