git常用命令
git init
git add file1 [file2 ...]
git add .
git add *
git commit -m "mark"
git log
git reflog
git reset --hard hash
git checkout -- file(做了修改,但是没有add或者commit,回到最近一次add或者commit的时候)
git checkout . (放弃所有的修改)
git reset HEAD <file>(将暂存区的修改撤销掉)
git rm <file>(如果误删,git checkout -- <file>)
git rm dir -r -f
git remote add origin url
git push -u origin master(第一次,之后可以git push -u origin master)
git branch
git checkout -b dev(等于git branch dev + git checkout dev)
git branch dev
git checkout dev
git branch
git merge dev(合并某分支到当前分支,需要切换到要合并的那个分支上)
git branch -d dev
git switch -c dev(创建并切换到dev,新版本)
git switch master(切换到dev,新版本)
git merge --no-ff -m "merge with no-ff" dev
git log --graph --pretty=oneline --abbrev-commit(查看合并情况)
git branch --set-upstream-to=origin/dev dev
//添加标签
git tag -a v0.1 -m "version 0.1 released" 043e06c
//删除本地标签
git tag -d v0.1
//推送指定的标签
git push origin <tagname>
//推送所有标签
git push --tags
//列出所有标签
git tag
//删除远程标签
git push origin :refs/tags/标签名
git push origin :refs/tags/protobuf-2.5.0rc1
git rm --cached <file_name> //.gitignore只对尚未被git追踪的文件有效,如果你要ignore的文件已经被添加到git仓库中了,可以使用如下命令移除
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
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
上次更新: 2024/01/07, 07:44:52