git学习总结(三)

来源:互联网 发布:php获取ip地理位置 编辑:程序博客网 时间:2024/06/08 16:24

1.查看本机关联的远程仓库

git remote

2.删除本机关联的远程仓库

git remote rm <name>

3.关联一个远程库

git remote add origin git@server-name:path/repo-name.git

4.向远程库推送内容

git push -u origin master,第一次推送master分支的所有内容,此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改

5.从远程库克隆

git clone <path>

6.创建并合并分支

git checkout -b <name>

相当于:

git branch <name>

git checkout <name>

7.查看当前分支

git branch:列出所有分支,当前分支前面会标一个*号

8.合并分支

git merge

9.删除分支

git branch -d <name>

10.查看分支合并情况

git log --graph --pretty=oneline --abbrev-commit

11.合并分支时禁用fast forward

git merge --no-ff -m "<note>" <name>

12.存储工作区状态

git stash

13.查看存储的工作区状态列表

git stash list

14.恢复存储的工作区状态

git stash apply:恢复后,stash内容并不删除,你需要用git stash drop来删除

git stash pop:恢复的同时把stash内容也删了

15.强行删除一个没有被合并过的分支

git branch -D <name>

16.链接本地分支和远程库指定分支

git branch --set-upstream <name> origin/<name>

17.在本地创建和远程分支对应的分支

git checkout -b branch-name origin/branch-name

0 0
原创粉丝点击