分支
- 查看本地分支
git branch
- 查看本地和远程分支
git branch -a
git branch --all
- 更新本地的远程分支列表
git remote update origin --prune
git remote update origin -p
git fetch -p
- 删除本地分支
git branch --delete <branchName>
git branch -d <branchName>
- 删除远程分支
git push origin --delete <branchName>
- 切换分支
git checkout <branchName>
- 创建本地分支
git branch <branchName>
- 创建并拉取远程分支到本地(本地不存在时)
git checkout -b <branch> origin/<remoteBranch>
本地储藏
- 储藏
git stash
- 查看现有的储藏列表
git stash list
-
使用储藏的
- 使用最近的储藏并应用
git stash apply
- 使用指定的储藏
git stash apply stash@{1}
- 使用储藏,同时暂存的也保持一致
git stash apply --index
删除储藏指定的列表
git stash drop stash@{0}
- 应用并删除
git stash pop
关联远程分支地址
- 关联远程分支
git remote add origin git@xxxx:xxxx.git
- 关联后,第一次推送master分支的所有内容
git push -u origin master
- 此后,每次本地提交
git push origin master