- git clone {url} 克隆一个版本库
- git remote add local_proj /opt/git/project.git 增加一个远程版本库
- git branch 查看现有分支
- git checkout {分支名} 切换到现有分支
- git checkout -b {分支名} 在本地建立新分支
- git push --set-upstream origin {远端分支名} 将新建的本地分支上传到服务器
- git fetch/ git pull 将新的分支信息更新到本地
- git checkout --track origin/{新分支名} 或 git checkout -b {本地分支名} origin/{远程分支名} 本地开始跟踪新分支
- git branch -d {本地分支名} 删除本地分支
- git ls-remote 查看远程分支,tag
- git push origin --delete server fix 删除远程分支
- git branch -v 查看本地分支和远程分支对应关系
- git branch -vv 查看本地分支和远程分支对应关系详情
- git remote -v 查看远程服务器情况
- git merge {分支名} 将分支合并到当前分支
- git mergetool 启动外部UI工具合并冲突
- git config --global mergetool.keepBackup false 设置不自动生成备份文件
- git reset [--soft][—mixed][—hard] HEAD^ 或 HEAD~2 重置HEAD指针为上次提交,soft:不重置索引区、工作目录,mixed:不重置工作目录,hard:全重置,包括工作目录
- git rm {文件名} git rm -f {目录名} 删除版本库中的文件
- gti tag {标签名} 给当前状态打标签
- git stash | git stash apply | git stash list | git stash pop | git stash clear暂存工作区中的文件,不提交,切换到其他分支
- git format-patch | git am 生成离线补丁文件 | 通过补丁文件打补丁
- git clean 删除版本库中不存在的文件,git clean 参数 -n 显示 将要 删除的 文件 和 目录 -f 删除 文件,-df 删除 文件 和 目录
- 设置 alias
$HOME/.gitconfig
[alias]
[alias]
lg = log --graph --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
--show-signature
st = status
l = log --pretty=oneline -n 20 --graph --abbrev-commit
ll = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
b = branch
ci = commit
ca = commit -a
pl = pull
ps = push
l = log --pretty=oneline -n 20 --graph --abbrev-commit
ll = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --
b = branch
ci = commit
ca = commit -a
pl = pull
ps = push
co = checkout
25. 设置merge tool为Beyond compare
git config --global diff.tool bc3
git config --global difftool.prompt false
git config --global merge.tool bc3
26. 设置sourceTree 使用 BeyondCompare
- Open SourceTree
- Open "Preferences" from the SourceTree menu
- Along the top bar, choose the "Diff" tab.
- Under External Diff / Merge
- for Visual Diff Tool choose
Otherthen in the Diff Command enter/usr/local/bin/bcompand for Arguments enter$LOCAL $REMOTE - For Merge Tool choose
Otherand in Merge Command enter/usr/local/bin/bcompand for Arguments enter$LOCAL $REMOTE $BASE $MERGED
- for Visual Diff Tool choose

本文详细介绍了Git的基础命令,包括克隆、添加远程仓库、创建和切换分支、推送、拉取、删除分支、合并分支、标签管理、暂存与回滚、文件删除与打标签等功能。此外,还提供了设置个性化别名、配置Mergetool、使用SourceTree等高级用法。

299

被折叠的 条评论
为什么被折叠?



