设为首页 - 加入收藏 ASP站长网(Aspzz.Cn)- 科技、建站、经验、云计算、5G、大数据,站长网!
热搜: 创业者 数据 手机
当前位置: 首页 > 服务器 > 安全 > 正文

利用git提交代码的方法步骤(3)

发布时间:2020-08-21 01:30 所属栏目:53 来源:网络整理
导读:git pull orgin masterfatal: 'orgin' does not appear to be a git repositoryfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists. 正

git pull orgin master fatal: 'orgin' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

正确的应该是origin!!

如果在push的时候有如下输出:

$ git push -u origin master To https://git.oschina.net/liuqiqiang/LQQCircleShowImage.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'https://git.oschina.net/liuqiqiang/LQQCircleShowImage.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.

看提示可知道,需要先pull一下,即执行一次:git pull origin master

然后再执行:git push origin master

分支管理

新建分支

$ git branch newbranch

查看分支

$ git branch

输出:

* master newbranch

*代表当前所在的分支

切换分支

$ git checkout new branch

输出

Switched to branch 'newbranch'

切换后可用git branch查看是否切换到当前分支

master * newbranch

提交改动到当前分支

$ git add . $ git commit -a

可使用git status查看提交状态

接着切回主分支

$ git checkout master

输出:

Switched to branch 'master'

将新分支提交的改动合并到主分支上

$ git merge newbranch

输出:

Updating cc73a48..93a1347
Fast-forward
GitTest.xcodeproj/project.pbxproj | 9 +++++++++
.../UserInterfaceState.xcuserstate | Bin 0 -> 7518 bytes
GitTest/test.h | 13 +++++++++++++
GitTest/test.m | 13 +++++++++++++
4 files changed, 35 insertions(+)
create mode 100644 GitTest.xcodeproj/project.xcworkspace/xcuserdata/Artron_LQQ.xcuserdatad/UserInterfaceState.xcuserstate
create mode 100644 GitTest/test.h
create mode 100644 GitTest/test.m

这里我提交了两个文件,即:test.h和test.m

如果合并后产生冲突,可输入以下指令查看冲突:

$ git diff

修改之后,再次提交即可;

接下来,就可以push代码了:

$ git push -u origin master

这时可能需要你输入你的github用户名和密码,按照提示输入即可;

删除分支

$ git branch -D newbranch

输出

Deleted branch newbranch (was 93a1347).

以上就是最简单的github操作了,也是在网上看着学的,注意在实际操作中多加练习,代码这东西,刚开始桥的多了也就记下了!

(编辑:ASP站长网)

网友评论
推荐文章
    热点阅读