首页 > 杂记 > 正文

如何创建分支并提交代码

标签:macaca, git


如何创建分支并提交代码

1.首先查看分支信息


git branch
* create
  dev
  master

2.创建分支test


git branch test

查看分支是否创建成功  
git branch

* create
  dev
  master
  test

3.切换分支到test


git checkout test
Switched to branch 'test'

查看是否切换成功
git branch
  create
  dev
  master
* test

4.修改文件信息,比如这里添加一个文件


touch test
ls
macaca-test	package.json	test

5.由于添加了新文件,所以需要提交新文件上去

添加当前目录
git add .

提交到本地仓库
git commit -am '添加test文件'
[test 4d485cd] 添加test文件
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test

推送到远程仓库
git push origin test
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 286 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local objects.
To https://github.com/CodeToSurvive1/bank_sample.git
 * [new branch]      test -> test

6.直接通过web页面管理器查看是否已经提交到git上

成功截图

成功截图2

7.如果想删除本地分支或者远程仓库分支


git branch -D test
Deleted branch test (was e7c582b).

删除远程仓库分支

$ git push origin --delete test
To https://github.com/CodeToSurvive1/bank_sample.git
 - [deleted]         test


原创文章,转载请注明出处!
本文链接:https://codetosurvive1.github.io/posts/how-to-create-branch-and-commit.html
上篇: mapreduce程序如何设置没有reducer
下篇: mac系统搭建master-slave环境搭建(非docker版本)