githup 首次提交项目及分支 遇到的问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了githup 首次提交项目及分支 遇到的问题相关的知识,希望对你有一定的参考价值。


GITHUP提交项目遇到的问题,会遇到如下问题:


问题1:

 

 命令:git push -u origin master


[email protected] MINGW32 /d/workspace/email-server (master)
$ git push -u origin master:master
To 。。。。。。。。。
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to ‘、、、、、、                   t‘
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=fetch+merge]

git pull --rebase origin master


[email protected] MINGW32 /d/workspace/email-server (master)
$ git pull --rebase origin master
warning: no common commits
remote: Counting objects: 17, done.
remote: Compressing objects: 100% (11/11), done.
remote: Total 17 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (17/17), done.
From 。。。。。。。。。。。。。。。。。。
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: init commit
Using index info to reconstruct a base tree...


此时再执行语句 git push -u origin master即可完成代码上传到email-server


[email protected] MINGW32 /d/workspace/email-server (master)
$ git push -u origin master
Counting objects: 165, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (129/129), done.
Writing objects: 100% (165/165), 32.45 KiB | 0 bytes/s, done.
Total 165 (delta 75), reused 0 (delta 0)
remote: Resolving deltas: 100% (75/75), done.
To 。。。。。。。。。。。。。。。。。。。。
   06789e0..790d7f6  master -> master


这就可以了上传到上去了。


遇到这种问题还有人说是建立分支。

git branch new branch

查看分支是否创建成功

git branch

切换到新的分支

git checkout new branch

切换后可使用 git branch 确认是否切换成功。提交改动到新的分支

git add .
git commit -a



结束!



本文出自 “10093778” 博客,请务必保留此出处http://10103778.blog.51cto.com/10093778/1945467

以上是关于githup 首次提交项目及分支 遇到的问题的主要内容,如果未能解决你的问题,请参考以下文章

git的使用学习githup和码云的使用

github乱码

Git 项目提交代码及一些常用命令

git新建分支及代码提交

git项目提交及分支操作命令

Git命令cherry-pick,选择把一部分代码提交到另一个分支