git常用命令
git常用命令
参考地址:http://www.cnblogs.com/cspku/articles/Git_cmds.html
------------
git配置
/etc/gitconfig
# git config --system user.name "username"
$ git config --global user.name "username"
$ git config --global user.email "username@email.com"
$ git config --global core.edit vim[emacs]
$ git config --list
git初始化
将工作文件修改提交到本地暂存区
$ git add -A
$ git add .
$ git add *
Commit日志显示
$ git log
版本回退
$ git reset --hard [CommitNO.]
差异比较
$ git diff <file> # 比较当前文件和暂存区文件差异 git diff
git diff <id1> <id2> # 比较两次提交之间的差异
git diff <branch1> <branch2> # 在两个分支之间比较
分支管理
git branch #显示分支
git branch -a #显示所有分支
git branch -r # 查看远程分支
git branch -d <branch> # 删除某个分支
git branch -D <branch> #强制删除某个分支
git checkout <branch> #切换分支
git checkout -b <branch> #创建新分支
git merge <branch> #合并其他分支到当前分支
远程git
git remote -v #查看远程服务器地址和仓库名称
git remote show origin #查看远程服务器仓库状态
git remote add origin <地址> #添加远程仓库地址
git remote set-url origin <地址> #设置远程仓库地址(用于修改远程仓库地址)
git remote rm <repository> #删除远程仓库
git clone 地址 #克隆远程git库
git push -u origin master #客户端首次提交
git push -u origin develop #首次将本地develop分支提交到远程develop分支,并且track

浙公网安备 33010602011771号