为什么我不能结账新分行?

时间:2013-10-16 12:28:48

标签: git version-control github branch

所以我进入终端,由于某种原因,我在一个我不记得的分支上:

camel@therafer:~/hashrocket/poopgraph(ref: re...)

当我尝试使用gco master离开此分支时,它会告诉我:

camel@therafer:~/hashrocket/poopgraph(ref: re...)$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
    app/controllers/application_controller.rb
    app/controllers/users_controller.rb
    app/models/user.rb
    features/dump.feature

Please, commit your changes or stash them before you can switch branches.
Aborting

所以我继续尝试隐藏或提交分支,提交似乎没有做任何事情,因为当我执行git状态时,仍然会弹出一堆新文件,而stash只返回:

fatal: bad revision 'HEAD'
fatal: bad revision 'HEAD'
fatal: Needed a single revision
You do not have the initial commit yet

这让我抓狂,因为我只是继续进行,我似乎无法弄清楚为什么我的分支系统无效。

注意:我也尝试按照其他类似帖子的建议更改HEAD分支,但这不起作用。

3 个答案:

答案 0 :(得分:1)

嗯,我能够与更有经验的人取得联系,幸运的是他有一个简单的解决方案。他告诉我要跑:

    hcd

    rm -rf poopgraph

    git clone git@github.com:mrmicahcooper/poopgraph.git

这将我带出项目,然后从我的计算机中删除项目,最后一个命令只是将它从在线服务器github上添加回我的计算机。显然这个问题是一个技术错误,必定是一些怪异事故的结果,这不是一个正常的编程错误。

答案 1 :(得分:0)

尝试

git add .       //add all files to the staging area including unversioned filed
git commit -m "commit message"     //Commit

这会将所有文件添加到暂存区域,然后提交它们。

或者,如果您想丢失所有更改,还可以执行以下操作:

git checkout -- .  //checkout the last version of all files

然后尝试

git checkout branchName

答案 2 :(得分:-1)

使用以下命令

git checkout -b分支名称来源

仅将分支名称添加到branchname

相关问题