Github本地新建分支并推送远程仓库

有时候需要在本地新建了代码分支,想直接推送到远程仓库并新建代码分支,操作如下:

第一步,先初始化本地git仓库(如果是从远程仓库拉下来的可以忽略这一步)

damon@damon-Latitude-7380:Ntrip$ git init
Initialized empty Git repository in /home/damon/Work/ntrip/Ntrip/.git/

第二步,添加远程仓库:

damon@damon-Latitude-7380:Ntrip$ git remote add origin https://github.com/lxxxen/ntrip
damon@damon-Latitude-7380:Ntrip$ git remote -v
origin	https://github.com/lxxxen/ntrip (fetch)
origin	https://github.com/lxxxen/ntrip (push)

第三步,把本地的代码先commit:

damon@damon-Latitude-7380:Ntrip$ git status
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

	makefile
	ntripclient
	ntripclient.c
	serial.c
	startntripclient.sh

nothing added to commit but untracked files present (use "git add" to track)
damon@damon-Latitude-7380:Ntrip$ git add .
damon@damon-Latitude-7380:Ntrip$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   makefile
	new file:   ntripclient
	new file:   ntripclient.c
	new file:   serial.c
	new file:   startntripclient.sh

damon@damon-Latitude-7380:Ntrip$ git commit -m "NEW: new branch for ntrip serila."
[master (root-commit) ee026c3] NEW: new branch for ntrip serila.
 5 files changed, 1486 insertions(+)
 create mode 100755 makefile
 create mode 100755 ntripclient
 create mode 100755 ntripclient.c
 create mode 100644 serial.c
 create mode 100755 startntripclient.sh

第四步,新建本地分支并推送远程仓库:

damon@damon-Latitude-7380:Ntrip$ git branch
* master
damon@damon-Latitude-7380:Ntrip$ 
damon@damon-Latitude-7380:Ntrip$ 
damon@damon-Latitude-7380:Ntrip$ git branch test
damon@damon-Latitude-7380:Ntrip$ 
damon@damon-Latitude-7380:Ntrip$ git push origin test
Username for 'https://github.com': lxxxxx@126.com
Password for 'https://lxxxxx@126.com@github.com': 
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 25.23 KiB | 0 bytes/s, done.
Total 7 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'test' on GitHub by visiting:
remote:      https://github.com/lxxxxx/ntrip/pull/new/test
remote: 
To https://github.com/lxxxxx/ntrip
 * [new branch]      test -> test

完事!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值