-
Notifications
You must be signed in to change notification settings - Fork 0
/
git-kit.txt
112 lines (92 loc) · 2.68 KB
/
git-kit.txt
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
1.远程比较
git fetch origin
git log master ..origin/master
git diff --stat master origin/master
2.冲突处理
git add .
git commit
git merge
手工修改
git add .
git commit
git push
3.本地commit回退版本
使用Git log 及git reset commitId来实现。
git log
git reset
# 执行命令将conf下文件加入不提交队列
git update-index --assume-unchanged conf/*
# 执行命令将db.php取消加入不提交队列
git update-index --no-assume-unchanged conf/*
git remote -v
git remote remove origin
git remote add origin ssh:https://[email protected]:36353/app/gitrepo/aml-mini.git
git push --set-upstream origin master
git查看所有分支
要查看本地仓库的所有分支,可以使用如下命令:
$ git branch
如果要查看远程仓库分支,代码修改如下:
$ git branch --remote
4.分支操作
创建分支
git branch <branchname>
检出分支
git checkout <branchname>
查看分支分叉历史
git log --oneline --decorate --graph --all
新建分支并同时切换
git checkout -b <branchname>
same as
git branch <branchname>
git checkout <branchname>
工作分支
git checkout -b iss53
切出主线分支
git checkout master
创建hotfix分支
git checkout -b hotfix
git commit -a -m""
git push --set-upstream origin hotfix
新建一个远程分支
比如新建了一个叫dev的分支,而github网站上还没有,可以直接:
git push -u origin dev
重新切出主线分支
git checkout master
合并到主线分支
git merge hotfix
删除hotfix分支
git branch -d hotfix
切回工作分支
git checkout iss53
git remote add pb https://github.com/paulboone/ticgit #pb别名
git remote -v
git fetch pb
远程仓库的移除与重命名
$ git remote rename pb paul
$ git remote
$ git remote rm paul
导出新分支
[jerry@j aml-mini]$ git branch -a
* master
remotes/github/master
remotes/origin/master
[jerry@j aml-mini]$ git fetch github
来自 https://github.com/jerryzu/aml-mini
4ddc5fc..51cfa2f master -> github/master
* [新分支] nopart -> github/nopart
[jerry@j aml-mini]$ git branch -a
* master
remotes/github/master
remotes/github/nopart
remotes/origin/master
[jerry@j aml-mini]$ git checkout -b nopart github/nopart
分支 'nopart' 设置为跟踪来自 'github' 的远程分支 'nopart'。切换到一个新分支 'nopart'
你可以在合并冲突后的任意时刻使用 git status 命令来查看那些因包含合并冲突而处于未合并(unmerged)状态的文件:
9.git svn
git svn clone file:https:///tmp/test-svn -T trunk -b branches -t tags
git svn rebase
git svn dcommit
10.比较本地和远程的区别
git diff <localbranch> <remote/branch>
比如我的本地分支名为dev,远程分支名为dev。
git diff dev origin/dev