1 查看远程分支
git branch -a
2 查看本地分支
git branch
3 创建本地分支 local_branch
git branch local_branch
4.把分支推到远程分支
git push origin <branchName>
5 切换到分支local_branch
git checkout local_branch
6 删除本地分支local_branch
git branch -d local_branch
7 删除远程分支remote_branch
git push origin --delete <branchName>
或(注意:前的空格,推送一个空分支到远程分支,其实就相当于删除远程分支)
git push origin :remote_branch
删除远程Tag
git push origin --delete tag <tagname>
8 本地提交
git commit -am "注释"
9 推送本地分支local_branch到远程分支 remote_branch并建立关联关系
a.远程已有remote_branch分支并且已经关联本地分支local_branch且本地已经切换到local_branch
git push
b.远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
git push -u origin/remote_branch
c.远程没有有remote_branch分支并,本地已经切换到local_branch
git push origin local_branch:remote_branch
10 本地代码库回滚
git reset --hard commit-id :回滚到commit-id,讲commit-id之后提交的commit都去除
git reset --hard HEAD~3:将最近3次的提交回滚
11.删除掉没有与远程分支对应的本地分支
git fetch -p
12.修改 remote 的url
git remote set-url origin newUrl
GIT教程:
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
http://blog.jobbole.com/76843/