GIT
初始化
git config --global user.name "your_name"
git config --global user.email "your_email@example.com"
git config core.fileMode false
git config --global core.fileMode false
git update-index --assume-unchanged <file>
git ls-files -m | xargs git update-index --assume-unchanged
git update-index --no-assume-unchanged <file>
git ls-files -v | grep '^h' | awk '{print $2}' | xargs git update-index --no-assume-unchanged
git status -u | grep $'\t' | sed 's/^[\t]//g' >> .gitignore
ssh-keygen -t rsa -C <mail>
ssh -T git@gitee.com
cat ~/.ssh/id_rsa.pub
eval `ssh-agent -s`
ssh-add "私钥文件地址"
git remote set-url origin git@git.zhkj-rd.cn:app/cms.git
分支操作
git branch <branch-name>
git checkout <branch-name>
git checkout -b <branch-name>
git remote prune origin
git push origin <branch-name>
git push origin --set-upstream/-u <origin> <branch-name>
git push origin :<branch-name>
git push -d origin <branch-name>
git branch -d/D <branch-name>
git merge <branch-name>
git format-patch -1 [hash-id]
patch -p1 < xx.patch
git cherry-pick <hashID>
git cherry-pick <hashID>:单独合并一个提交
git cherry-pick <start-hashID>..<end-hashID>(左开右闭,不包含start-hashID)
git cherry-pick <start-hashID>^..<end-hashID>(闭区间,包含start-hashID)
查看修改
qgit
gitk
smartGIT
git diff file
git diff --cached file
git show <hashID> --stat
git show <hashID> file
git show <hashID>
git log
git log -p
git log --stat
git log --author=<username>
git log --pretty=oneline
git log --oneline
git log --oneline --graph --all
git config --global diff.tool bcompare
git config --global difftool.prompt false
git config --global merge.tool bc
git config --global mergetool.bc.path "/usr/bin/bcompare"
git config --global mergetool.bc.trustexitcode true
||
git config --global merge.tool bcompare
git config --global mergetool.prompt false
git config --global mergetool.keepBackup false
git difftool -y <file>
git difftool --no-symlinks -d
git difftool --no-symlinks -d <hashID> <hashID>
git rev-list HEAD
提交还原操作
git checkout -- file
git reset HEAD file
git reset --soft <hashID>
git reset --hard <hashID>
git revert <hashID>
git rebase -i HEAD~2
git clean -dxf
常用配置
git config --global alias.st status -uno
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.br branch
git config --global alias.mt mergetool
git config --global alias.dt "difftool --no-symlinks -d"
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"
git config --global core.quotepath false
git config --global color.ui true
https://github.com/github/gitignore
find . -type d -empty | awk -F' ' '{print "mkdir -p " $0}'
find . -type d -empty -exec touch {}/.gitkeep \;
git常用操作
git checkout <hash> <filename>
git commit --amend -m "新的修改提交信息"
git branch --set-upstream-to=origin/<branch>
GIT-SVN
git svn clone -r12000:HEAD http://xx /home/xx --username=***
git svn dcommit
git svn rebase
SVN
svn add --no-ignore
svn st compatible_branch/ | grep "\.c$"
svn st compatible_branch/ | grep "\.h$"
svn st -q
svn st ./ | grep "^?" | awk '{print $2}' | xargs rm -rf
svn merge -r 7876:7875 ./
svn log -r 7876 -v
svn diff -r 7875:7876
snv log -l 10
svn cp -m "" http:// http://
svn switch http://