天天看点

git命令使用

2015-07-15 11:59:11

git pull : 相当于 SVN up

git status : 相当于 SVN st

git add a.txt: 新添加文件 或者 将文件修改保存到索引中, 和SVN add的作用一样

git checkout -- a.txt : 忽略本地对a.txt的更改, 将其改回之前的版本 (注意两个减号)

git commit a.txt : 提交到本地存储

git push : 提交到远程版本库中, 相当于 SVN ci

查看本地分支: git branch

查看远程分支: git branch -r

查看本地和远程分支: git branch -a

删除本地分支: git branch -D <branchName>

删除远程分支: 

    方法一: git push origin --delete <branchName>

    方法二: git push origin :<branchName>

本地新建了分支, 需要同步到远程版本库中, 让其它小伙伴看到

git push origin 本地分支名:远程分支名

从远程检出分支到本地作为新的本地分支

git checkout -b 本地分支名 origin/远程分支名

设置本地分支与远程分支关联