0

我只是做了一些更改,然后提交,但是当我尝试推送时,我收到一个错误,表明一切都是最新的。

为什么会发生这种情况?作为说明,昨天我遇到了一些合并问题,今天我不得不做一个 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.
4

2 回答 2

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不会处理未跟踪的文件)

于 2013-02-07T17:10:37.640 回答
0

你需要

git add FILENAME

或者

git commit -a

否则你什么都没有提交。

您的 git 输出告诉您有未暂存和未跟踪的文件,这是因为您刚刚执行了“git commit 文件名”,除非您使用 git add 暂存文件,否则它不会做任何事情。

你也可以通过

git log

您本地的历史记录与远程的历史记录相同,因此 git 消息“一切都是最新的,没有变化”

于 2013-02-07T16:31:08.723 回答