`

解决failed to push some refs to git和Git Cannot rebase: You have unstaged changes.

    博客分类:
  • Git
git 
阅读更多


 1.
在使用git 对源代码进行pushgitHub时可能会出错,信息如下:

 


2.此时很多人会尝试下面的命令把当前分支代码上传到master分支上。

$ git push -u origin master

但依然没能解决问题



 

 

 

 

3.出现错误的主要原因是github中的README.md文件不在本地代码目录中



 

 

4.可以通过如下命令进行代码合并【注:pull=fetch+merge]

git pull --rebase origin master

 



 
5、此时又出现了另外一个问题:cannot pull with you have unstaged changes

这说明“有修改过的文件,但是没有放到暂存区”,因此使用
git stash

 

然后再git pull --rebase (每次push之前最好这样做一次)就可以正常提交了。
 

 

 

6.执行上面代码后可以看到本地代码库中多了README.md文件

 



 

 

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

 



 

  • 大小: 70 KB
  • 大小: 228.6 KB
  • 大小: 173 KB
  • 大小: 77.2 KB
  • 大小: 33.5 KB
  • 大小: 89.9 KB
  • 大小: 69.7 KB
分享到:
评论

相关推荐

    解决fatal:remote error:You can’t push to git://github.com/username/*.git问题的办法

    解决fatal:remote error:You can’t push to git://github.com/username/*.git问题的办法 今天Git push的时候 fatal:remote error: You can't push to git://github.com/username/*.git Use git@github....

    error: failed to push some refs to 'https://gitee.com/xiao-long

    学习git的基本操作时,遇到问题error: failed to push some refs to 'https://gitee.com/xiao-longlong/git-test.git' 解决办法:先执行git pull --rebase origin master 然后执行git push origin master即可

    关于gitee push 不上 报错原因

    error: failed to push some refs to 'git@gitee.com:yanxiaoxin98/hair.git' 死都push不上去

    Github—failed to push some refs to ‘https://github.com/***/git_project.git’解决办法

    Github—failed to push some refs to ‘https://github.com/***/git_project.git’解决办法报错详情 报错详情 git version 2.26.2.windows.1 因为没有提交内容到master,需要先提交 先设置User.email、user.name ...

    repo,解决fatal: Cannot get https://gerrit.googlesource.com/git-repo

    18年7月更新,清华镜像,完美解决 Yocto,Android fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle 错误,绕开GFW

    Vue 解决通过this.$refs来获取DOM或者组件报错问题

    如果ref属性加在普通元素上,那么this.$refs.name则指向该DOM元素 ”p”>hello <!– this.$refs.p 指向该DOM元素 –> 如果ref属性加在组件上,那么this.$refs.name指向该组件实例 ”child”> <!– this.$...

    git提交项目到码云步骤及出现问题解决办法

    error: failed to push some refs to 'https://gitee.com/heguxin/cas_fn.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by ...

    git推送项目命令.pdf

    1. **错误:failed to push some refs**:通常是因为本地分支与远程分支有冲突,需要先合并或解决冲突。 2. **未合并的文件**:使用`git pull --rebase origin master`先拉取远程更改,再解决冲突,最后`git push ...

    Git发现git push origin master 报错的解决方法

    git push origin master 报错的解决方法,分享给大家,具体如下: 错误提示如下 ...error: failed to push some refs to 'git@github.com:kangvcar/Results-Systems--PHP.git' hint: Updates were r

    git常用命令和冲突解决.doc

    Git 常用命令和冲突解决 Git 是一个免费、开源的分布式版本控制系统,能够记录每一次更新,并与他人协作。下面是一些 Git 常用的命令和冲突解决方法。 一、远程仓库相关命令 1.检出仓库:`$ git clone git://...

    解决 github项目clone报错 Failed connect to github.com:443; Connection

    系统环境:CentOS Linux release 7.6.1810 (Core)  起因:npm构建时报错 ... fatal: unable to access 'https://github.com/nhn/raphael.git/': Failed connect to github.com:443; Connection timed out npm

    Git.framework.zip

    Resolving refs from .git/refs Reading branches, both local and remote Enumeration of commits in breadth and depth first orders Rev-list Support to a certain degree, full compatibility with git ...

    Git-2.21.0-64-bit.zip

    * "git help git" was hard to discover (well, at least for some people). * The pattern "git diff/grep" use to extract funcname and words boundary for Rust has been added. * "git status" can be ...

    null.sys 修复Git异常

    7. **社区求助**:如果以上方法都无法解决问题,可以在GitHub的Git帮助论坛或者Stack Overflow等技术社区提问,提供详细的问题描述和错误信息,寻求其他开发者的经验和解决方案。 总的来说,修复Git异常需要耐心和...

    Git常见错误解决1

    #### 错误三:`error: failed to push some refs to ...` **问题描述:** 在尝试推送更改到远程仓库时可能会遇到此错误,通常是因为远程仓库与本地仓库的状态不一致。 **解决步骤:** 1. **同步远程仓库:** - ...

    整理的一些常用的git命令

    - 如果遇到 "failed to push some refs" 错误,可能是因为本地和远程有冲突。先用 `git pull --rebase origin master` 拉取并解决冲突,然后再次尝试推送。 5. **克隆仓库**: - `git clone <repository>` 用于从...

    T-blog:由node.js服务的个人博客

    会报错error: failed to push some refs to 'git@github.com:fatpandaria/T-blog.git' hint: Updates were rejected because the tip of your current branch is behind,这是因为没有git pull,一般进行push要先...

    git命令git命令git命令git命令

    5. 删除远程标签:`git push origin :refs/tags/[tagName]` 6. 查看标签信息:`git show [tag]` ### 远程同步 与远程仓库交互: 1. 推送本地分支到远程:`git push origin [branch]` 2. 强制推送(覆盖远程分支)...

    Git push 常见用法

    ### Git Push 常见用法详解 #### 概述 `git push` 是一个用于将本地仓库中的更改同步到远程仓库的命令。通过执行 `git push`,开发者能够将本地所做的修改、新添加的文件或者对现有文件的更改同步到远程仓库中,...

Global site tag (gtag.js) - Google Analytics