某些文件的git推送错误

时间:2016-11-21 01:48:13

标签: git

我想提交一个文件来使用git来掌握,我已经关注了这个链接: How to push certain files to origin/master in git?

现在当我推动我的更改时,会收到错误。我该如何解决?

$ git checkout master
M       project/Build.scala
M       project/plugins.sbt
A       XX/src/main/resources/a.properties
M       XX/src/main/resources/project.conf
D       XX/src/main/scala/X.scala
M       XX/src/test/scala/Y.scala
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 8 commits.
  (use "git push" to publish your local commits)

$ git push
Password for 'https://CCC@ibgit.com:8443':
To https://CCC@ibgit.com:8443/scm/xxx.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://CCC@ibgit.com:8443/scm/xxx.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.
$ git pull
error: Cannot pull with rebase: You have unstaged changes.
error: Additionally, your index contains uncommitted changes.

1 个答案:

答案 0 :(得分:3)

好像你有未分期/未提交的更改。您需要先使用以下命令提交更改:

git commit -m 'Your commit message'

然后使用以下命令从遥控器中提取最新代码:

git pull origin master

使用第一个命令再次提交合并代码。完成所有这些步骤后,尝试使用以下命令再次推送代码:

git push origin master

希望这会有所帮助。 欢呼声。