全局配置Git用戶名和郵箱
git config --global user.name "xxx"
git config --global user.email "xxx@xx.com"
添加單個文件或者多個文件到暫存區(qū)
git add xx1 xx2
添加當前更改的所有文件到暫存區(qū)
git add .
提交暫存的更改,并新開編輯器進行編輯
git commit
提交暫存的更改,并備注信息
git commit -m "message..."
等同于 git add . && git commit -m的命令
git commit -am
對最近一次的提交的信息進行修改,此操作會修改commit的hash值
git commit --amend
使用git fetch獲取遠程倉庫特定分支的更新
git fetch <遠程主機名> <分支名>
獲取遠程倉庫所有分支的更新
git fetch --all
git pull拉取遠程倉庫指定分支的代碼并合并
# git pull 等同于 git fetch && git merge
git pull <遠程主機名> <遠程分支名>:<本地分支名>
使用rebase的模式進行合并
git pull --rebase <遠程主機名> <遠程分支名>:<本地分支名>
新建本地分支,但不切換
git branch <branch-name>
查看本地分支
git branch
查看遠程分支
git branch -r
查看本地和遠程分支
git branch -a
刪除本地分支
git branch -D <branch-nane>
重新命名分支
git branch -m <old-branch-name> <new-branch-name>
查看遠程倉庫
git remote -v
添加遠程倉庫
git remote add 倉庫名 地址