git命令
Posted dengrenning
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git命令相关的知识,希望对你有一定的参考价值。
远程仓库
由于你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要一点设置:创建SSH Key:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001374385852170d9c7adf13c30429b9660d0eb689dd43a000
$ ssh-keygen -t rsa -C "[email protected]"
$ 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 [email protected]: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 ode_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命令的主要内容,如果未能解决你的问题,请参考以下文章
VSCode自定义代码片段15——git命令操作一个完整流程
GitGit 分支管理 ( 克隆远程分支 | 克隆 master 分支 git clone | 查看远程分支 git branch -a | 克隆远程分支 git checkout -b )(代码片段
GitGit 分支管理 ( 克隆远程分支 | 克隆 master 分支 git clone | 查看远程分支 git branch -a | 克隆远程分支 git checkout -b )(代码片段