-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgit3.txt
More file actions
73 lines (59 loc) · 3.12 KB
/
git3.txt
File metadata and controls
73 lines (59 loc) · 3.12 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
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
【1】查看、删除远程分支或tag
git branch -a
git push --delete origin <branchName>
git push --delete tag <tagname>
推送一个空的分支或tag到远端相当于删除操作
git push origin :<branchName>
git tag -d <tagname>
git push origin :refs/tags/<tagname>
【2】远程分支删除以后,本地pull或fetch都不会删除本地的对应分支,并且也看出哪些远程分支被删除掉了,但是由于本地还有track信息所以在branch中还可以被看到。
查看远程分支与本地分支的跟踪情况
git remote show origin
stale状态的分支即已经被删除的分支,可再用以下命令彻底删除掉所有的远端分支,再用git branch -a就看不到了这些远程分支了
git remote prune origin
在fetch之后删除没有远程分支对应的本地分支
git fetch -p
【3】重命名远程分支=删除远程分支+本地分支重命名再次推送
git branch -av //显示所有的分支及其的最后一次修改信息
git push --delete origin branch-name
git branch -m old-name new-name //重命名本地分支
git push origin new-name
另外在github中,用推送的方法不能删除远端当前HEAD指向的分支,除非你在github设置中将默认分支改为其他分支,否则该默认分支不可被删除。
【4】TAG(用的较少,一般都是直接pull把整个工作环境拉下来,不用考虑这些)
把本地tag推送到远程
git push --tags
获取远程tag
git fetch origin tag <tagname>
【5】commit注释
通过git config命令配置commit_template
git config --global commit.template template-file
设置git commit时填写注释所用的编辑器
git config --global core.editor vim
代码提交命令
git push origin HEAD:refs/for/branchname
git config --list
【6】git add用法
git add -u:将文件的修改、文件的删除,添加到暂存区。
git add .:将本目录下所有文件的修改,文件的新建,包括未跟踪的新文件添加到暂存区。
git add -A:将文件的修改,文件的删除,文件的新建,添加到暂存区。
【7】git clean用法
# 删除 untracked files
git clean -f
# 连 untracked 的目录也一起删掉
git clean -fd
# 连 gitignore 的untrack 文件/目录也一起删掉 (慎用,一般这个是用来删掉编译出来的 .o之类的文件用的)
git clean -xfd
# 在用上述 git clean 前,墙裂建议加上 -n 参数来先看看会删掉哪些文件,防止重要文件被误删
git clean -nxfd
git clean -nf
git clean -nfd
【8】没有change-id
curl http://10.120.10.101:9999/tools/hooks/commit-msg > .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
【9】
git clone ssh://username@10.120.10.101:29418/msm8939-la-2-1 -b mobeeplus01a-s11a_5_1_2156_15
repo init -u git://10.120.10.101/msm/platform/manifest.git --repo-url=git://10.120.10.101/msm/tools/repo.git -b ckt -m mobeeplus01a-s11a_5_1_2156_15_MSM8939.LA.2.1.xml
repo init -u git://10.120.10.101/msm/platform/manifest.git --repo-url=git://10.120.10.101/msm/tools/repo.git -b ckt -m mirage01a_s25a_5_1_mp_2156_15_MSM8939.LA.2.1.xml
============
mirage01a_s25a_5_1_mp_2156_15_MSM8939.LA.2.1.xml
mobeeplus01a-s11a_5_1_2156_15_MSM8939.LA.2.1.xml