forked from michaelliao/learngit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_gothub_push_test
65 lines (46 loc) · 2.22 KB
/
my_gothub_push_test
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
1. 初始化仓库,git init
2. 添加文件到仓库,分成两步
(1)git add file 可多次反复使用,添加多个文件。
(2)git commit -m <message>
git reset --hard commit_id 恢复版本
git log 查看提交历史
git reflog 查看历史命令
git checkout -- <file> 未使用add指令放到缓冲区时丢弃工作区的修改。恢复至最近一次git commit 或 git add的状态。
使用add指令放到缓冲区后,先git reset HEAD <file> 丢弃修改。然后再调用git checkout -- <file> 恢复。
删除文件:
rm -rf readme.txt
git rm readme.txt
git commit -m "remove file"
远程仓库:
1. 添加远程库
关联一个远程库:git remote add origin [email protected]:hanchaosdu/repositry_name.git
第一次提交:git push -u origin master
以后提交推送修改:git push origin master
2. 从远程库克隆
git clone [email protected]:hanchaosdu/reposity_name.git
分支管理:
git checkout -b dev 创建dev分支,切换到dev分支
相当于 git branch dev 创建分支dev
git checkout dev 切换分支dev
然后 git add, git commit都会提交至dev分支。
dev分支合并,先切换至master分支,git checkout master,然后git merge dev用于合并制定分值到当前分支。
删除分支:git branch -d dev 删除dev分支。
总结:
git branch 查看分支
git branch <name> 创建分支
git checkout <name> 切换分支
git merge <name> 合并分支
git branch -d <name> 创建并切换分支
git branch -d <name> 删除分支
修复bug时,创建新的bug分支进行修复,然后合并,最后删除。
当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,再git stash pop,回到工作现场。
丢弃一个没有合并的分支,通过git branch -D <name>强行删除。
git remote 查看远程库的信息,-v 显示更详细的信息。
标签:
git tag <tagname>新建一个标签
git tag -a <tagname> -m "information" 指定标签信息
git tag 查看所有标签
git push origin <tagname> 推送一个本地标签
git push origin --tags 推送全部未推送过的本地标签
git tag -d <tagname> 删除一个本地标签
git push origin :refs/tags/v0.9 删除一个远程标签