-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub.txt
More file actions
30 lines (30 loc) · 1.8 KB
/
github.txt
File metadata and controls
30 lines (30 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//查看分支合并情况
git log --graph --pretty=oneline --abbrev-commit
//合并指定分支dev,并且禁用Fast forward模式
git merge --no-ff -m "merge with no-ff" dev
//保存当前分支的操作,就像一个镜像
git stash
//查看当前分支的镜像
git stash list
一是用git stash apply恢复,但是恢复后,stash内容并不删除,
你需要用git stash drop来删除;
另一种方式是用git stash pop,恢复的同时把stash内容也删了:
你可以多次stash,恢复的时候,先用git stash list查看,然后恢复指定的stash,
用命令:git stash apply stash@{0}
//强行删除某个分支
git branch -D feature-vuloan
因此,多人协作的工作模式通常是这样:
首先,可以试图用git push origin branch-name推送自己的修改;
如果推送失败,则因为远程分支比你的本地更新,
需要先用git pull试图合并;
如果合并有冲突,则解决冲突,并在本地提交;
没有冲突或者解决掉冲突后,再用git push origin branch-name推送就能成功!
如果git pull提示“no tracking information”,
则说明本地分支和远程分支的链接关系没有创建,
用命令git branch --set-upstream branch-name origin/branch-name。
查看远程库信息,使用git remote -v;
本地新建的分支如果不推送到远程,对其他人就是不可见的;
从本地推送分支,使用git push origin branch-name,如果推送失败,先用git pull抓取远程的新提交;
在本地创建和远程分支对应的分支,使用git checkout -b branch-name origin/branch-name,本地和远程分支的名称最好一致;
建立本地分支和远程分支的关联,使用git branch --set-upstream branch-name origin/branch-name;
从远程抓取分支,使用git pull,如果有冲突,要先处理冲突。