码迷,mamicode.com
首页 > 其他好文 > 详细

git命令

时间:2018-09-15 13:54:11      阅读:130      评论:0      收藏:0      [点我收藏+]

标签:int   ranch   tin   set   sam   origin   rds   ref   another   

远程仓库

由于你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置:创建SSH Key:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374385852170d9c7adf13c30429b9660d0eb689dd43a000

$ ssh-keygen -t rsa -C "youremail@example.com"
$ git add readme.txt 
$ git commit -m "branch test"

创建dev分支,然后切换到dev分支:
	$ git checkout -b dev
	Switched to a new branch ‘dev‘
用git branch命令查看当前分支:
	$ git branch
	* dev
	  master
	  
	 
	 
关联远程库
	 $ git remote add origin git@github.com:michaelliao/learngit.git

$ git push -u origin master
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (20/20), 1.64 KiB | 560.00 KiB/s, done.
Total 20 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.
To github.com:michaelliao/learngit.git
 * [new branch]      master -> master
Branch ‘master‘ set up to track remote branch ‘master‘ from ‘origin‘.


报错:
F:\game_project\node_project>git push -u origin master
To https://gitee.com/cn_xxxxx/node.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to ‘https://gitee.com/cn_xxxxx/node.git‘
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull ...‘) before pushing again.
hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.
解决:
1、先拉下来,会自动合并的(不用操心)
	git pull origin master

2、再上传
	git push -u origin master

  

git命令

标签:int   ranch   tin   set   sam   origin   rds   ref   another   

原文地址:https://www.cnblogs.com/dengrenning/p/9650668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!