搜索
您的当前位置:首页正文

Git工作流及常用命令

来源:知库网

Git安装

用户信息配置

git config --global user.name "John Doe"
git config --global user.email 

git config --list

Git基本命令

work flow

git clone
git checkout -b branch_name origin/develop
    coding...
    coding...
git commit -a -m "wa"
git push origin branch_name
    merger request...
    compare
git pull
    auto merge...
    or by hand
git push

其他命令

git branch -r  # 远程分支
git branch -a  # 所有分支
git branch -d / -D  # 删除

git pull = git fetch + merge to local

git diff # 尚未保存的与暂存区的diff
git diff --staged  # 已经暂存的将要添加到下次提交的内容

git log --graph
git log --pretty=format:"%h - %an, %ar : %s"

# 例如,你提交后发现忘记了暂存某些需要的修改,可以像下面这样操作:

git commit -m 'initial commit'
git add forgotten_file
git commit --amend
Top