运行 git pull origin master 时出错
我是使用 git 版本控制的新手,在运行 git pull origin master
时遇到此错误,这就是错误:
From /opt/mygit/abc
* branch master -> FETCH_HEAD
error: Untracked working tree file 'nbproject/private/rake-d.txt' would be overwritten by merge. Aborting
我错过了什么吗?提前致谢。 :D
I'm a newbie in using git version control, I got this error when running git pull origin master
, this is the error :
From /opt/mygit/abc
* branch master -> FETCH_HEAD
error: Untracked working tree file 'nbproject/private/rake-d.txt' would be overwritten by merge. Aborting
Am I miss something? thanks in advance. :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您的本地存储库中似乎有文件
nbproject/private/rake-d.txt
,但 git 未跟踪该文件。同时,自上次拉取以来它已被添加到远程存储库,因此执行拉取会覆盖该文件,因此 git 会警告您这种情况会发生并中止拉取。
要解决此问题,您需要删除或重命名该文件。
如果您想自动执行此操作,请运行 git clean 来清理文件夹中未跟踪的文件(即删除它们)。不过,首先运行 git clean -n 可能是个好主意,它只会列出要删除的文件,让您查看是否有任何重要的文件计划删除。
或者,您可以将文件添加到存储库(记住提交它),然后拉取。然后 git 会尝试将本地副本与远程副本合并。
It would appear that you have the file
nbproject/private/rake-d.txt
in your local repository, but not tracked by git.Meanwhile, it has been added to the remote repository since your last pull, so doing a pull would overwrite that file, and thus git is warning you that that would happen and aborting the pull.
To resolve this, you'll need to go and either delete or rename the file.
If you want to automate this, run a
git clean
to clean out the folder of untracked files (that is, delete them). It might be a good idea to rungit clean -n
first, though, which merely lists the files it's going to delete, letting you see if there's anything important it plans on deleting.Alternatively, you could add the file to the repository (remember to commit it), and then pull. git will then try to merge your local copy with the remote one.
您可以首先使用
(或 git reset --hard HEAD )来清理未跟踪的文件,然后执行“
请记住,这将删除所有未跟踪的文件”
You could use first
(or git reset --hard HEAD ) to clean your untracked files then do a
Keep in mind this will delete any untracked files
您似乎正在使用 NetBeans 进行开发。我通常将此类特定于 IDE 的对象添加到 .gitignore。
It would appear that you're using NetBeans for development here. I generally add such IDE-specific objects to .gitignore.
您需要做的是删除本地未跟踪的副本。发生的情况是文件存在于远程,但不在本地。 git 不允许您覆盖本地未跟踪的文件。
你必须使用
ctrl+shift+F10
它很有用What you need to do is remove the local untracked copy. What's happening is that a file exists remotely, but not locally. git will not allow you to overwrite a local untracked file.
you have to use
ctrl+shift+F10
its useful如果您是新开始 git,请按照以下步骤操作:
假设您的 git 存储库 url 是 https://github。 com/absuser/repo.git
并且你想将你的项目推送到这个存储库上,分支名称为“testbranch”,你的代码位于你的机器上的“/home/ubuntu/Documents/code”
现在让我们开始:
按 ctrl +alt+T 打开你的终端。
在本地创建分支
$ git checkout -b testbranch
添加远程存储库
$ git Remote add origin https://github.com/absuser/repo.git
验证添加偏僻的
$ git remote -v
现在你的代码已经推送到 git 上了。
如果其他人也在同一分支上提交了代码,并且您想要将所有更改与本地计算机上的代码合并并推送到 git,请按照以下步骤操作:
首先,您必须标记所有更新的文件。
如果发生任何冲突,请解决该冲突并执行以下步骤,
否则继续
If you are newly started git then follow these steps :
Let's suppose your git repository url is https://github.com/absuser/repo.git
And you want to push your project on this repository with branch name 'testbranch' and your code on your machine at '/home/ubuntu/Documents/code'
Now let's start :
press ctrl+alt+T to open your terminal.
Create branch on local
$ git checkout -b testbranch
Add remote repository
$ git remote add origin https://github.com/absuser/repo.git
Verify added remote
$ git remote -v
Now your code pushed on git now .
In case if someone else also committed the code on same branch and you want to merge all the changes with your code on your local machine and push to git then follow these steps :
First you have to stagged your all updated files .
If any conflict occurs then resolved that and do following steps
otherwise go ahead