git常用命令
发布时间:2020-12-14 16:37:35 所属栏目:百科 来源:网络整理
导读:table class="text" tr class="li1" td class="ln"pre class="de1"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
<table class="text"> |
<tr class="li1">
<td class="ln"><pre class="de1">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
? git checkout ) ?
开始小功能开发,测试无误后,commit
git checkout [develop] ? ? 切到某个分支[develop]上
git merge feature-xxx(功能名) ? ? 将小功能分支合并到当前分支上
打个包,测试人员开始测试。如果有其他任务,按照上面的步骤再拉取分支并开发。
git branch -d feature-xxx(功能名) ? 将小分支删除
git branch -D ? 强行删除一个没有被合并过的分支
?
在远程仓库中新建分支
git remote -v ? 查看远程仓库信息
git checkout -b ? 先在本地创建一个分支
git push origin ? 将本地分支推送到远程仓库中,如果推送失败,先用git pull抓取远程的新提交(此时远程仓库会多一个分支)
git checkout -b branch-name origin/branch-name ? 在本地创建和远程仓库对应的分支
git branch --set-upstream branch-name origin/branch-name ? 建立本地分支和远程分支的关联
?
创建和编辑标签
git tag ? 查看所有标签
git tag ? 给HEAD,新建一个标签
git tag ? 给指定的一次提交,新建一个标签
git push origin ? 推送一个本地标签到远程仓库(如果name不存在会报错)
git push origin --tags ? 将本地所有的标签信息都推送到远程仓库
git tag -d ? 删除一个本地标签
git push origin :refs/tags/ ? 删除一个远程标签
?
参与开源项目
Fork ? 先将开源项目fork一份到自己的GitHub账号
Clone ? 然后从自己的账号下clone一份到本地
Pull Request ? 修改代码并提交到自己的远程仓库后,发起一个pull request,等待开源项目团队的审核
?
?
…or create a new repository on the command line(当先有本地仓库,后有远程仓库,没有readme.md文件时使用)
echo "# react-router-antd-mobx" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/movingStars/react-router-antd-mobx.git
git push -u origin master
?
…or push an existing repository from the command line(当先有本地仓库,后有远程仓库时使用)
git remote add origin https://github.com/movingStars/react-router-antd-mobx.git
git push -u origin master
…or import code from another repository(从另一个远程仓库贴代码过来)
You can initialize this repository with code from a Subversion,Mercurial,or TFS project.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!