我刚做了一些修改,然后提交了,但是当我试图推动时,我得到一个错误,一切都是最新的。
为什么会这样?作为一个说明,昨天我有一些合并问题,今天我不得不做一个git checkout some_version_number
知道这里出了什么问题吗? 谢谢!
以下是git status
的输出macoss-MacBook-Pro-10:Marketing owner12$ git status
# Not currently on any branch.
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Marketing/en.lproj/MainStoryboard_iPad.storyboard
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# Marketing.xcodeproj/project.xcworkspace/xcuserdata/owner12.xcuserdatad/
然后当我尝试通过git checkout master进入我的分支时,我得到了这个:
macoss-MacBook-Pro-10:Marketing owner12$ git push origin master
Password for 'https://genadinik@bitbucket.org':
Everything up-to-date
macoss-MacBook-Pro-10:Marketing owner12$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
Marketing/en.lproj/MainStoryboard_iPhone.storyboard
Please, commit your changes or stash them before you can switch branches.
error: The following untracked working tree files would be overwritten by checkout:
Marketing.xcodeproj/project.xcworkspace/xcuserdata/owner12.xcuserdatad/UserInterfaceState.xcuserstate
Please move or remove them before you can switch branches.
答案 0 :(得分:3)
根据您的git status
输出,您在不在主分支时进行了这些更改:
macoss-MacBook-Pro-10:Marketing owner12$ git status
# Not currently on any branch.
...
您的git checkout
未将您转移到master
分支的原因是,这样做会涉及覆盖您所做的更改(根据错误消息)。
最简单的方法是:
$ git stash save # Save the edits made whilst not on a branch
$ git checkout master # Move to the master branch
$ git stash pop # Apply stashed-changes; delete from stash if successful
请注意,应用更改可能会导致冲突 - 请务必仔细阅读任何git输出。
(编辑:请注意,git stash save
不会处理未跟踪的文件)
答案 1 :(得分:0)
你需要
git add FILENAME
或者
git commit -a
否则你什么也没提交。
你的git输出告诉你你有未分段和未跟踪的文件,这是因为你只是做了一个“git commit filename”,除非你用git add暂存文件,否则它不会做任何事情。
你也可以通过
看到这个git log
当地的历史与遥控器的历史相同,因此git消息“一切都是最新的,没有变化”