运行 git pull origin master 时出错

发布于 2024-10-14 12:47:48 字数 304 浏览 2 评论 0原文

我是使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

满身野味 2024-10-21 12:47:48

您的本地存储库中似乎有文件 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 run git 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.

欲拥i 2024-10-21 12:47:48

您可以首先使用

git clean -f -d

(或 git reset --hard HEAD )来清理未跟踪的文件,然后执行“

git pull

请记住,这将删除所有未跟踪的文件”

You could use first

git clean -f -d

(or git reset --hard HEAD ) to clean your untracked files then do a

git pull

Keep in mind this will delete any untracked files

双马尾 2024-10-21 12:47:48
 if you are getting the pulling error due to untracked worked....

 try it...

go to your project location



 $ cd /usr/local

    $ git fetch origin

    $ git reset --hard origin/master
 if you are getting the pulling error due to untracked worked....

 try it...

go to your project location



 $ cd /usr/local

    $ git fetch origin

    $ git reset --hard origin/master
思念满溢 2024-10-21 12:47:48

您似乎正在使用 NetBeans 进行开发。我通常将此类特定于 IDE 的对象添加到 .gitignore。

It would appear that you're using NetBeans for development here. I generally add such IDE-specific objects to .gitignore.

触ぅ动初心 2024-10-21 12:47:48

您需要做的是删除本地未跟踪的副本。发生的情况是文件存在于远程,但不在本地。 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

天涯沦落人 2024-10-21 12:47:48

如果您是新开始 git,请按照以下步骤操作:

假设您的 git 存储库 url 是 https://github。 com/absuser/repo.git

并且你想将你的项目推送到这个存储库上,分支名称为“testbranch”,你的代码位于你的机器上的“/home/ubuntu/Documents/code”

现在让我们开始:

按 ctrl +alt+T 打开你的终端。

$ cd /home/orange/Documents/code

$ git init

在本地创建分支
$ git checkout -b testbranch

添加远程存储库
$ git Remote add origin https://github.com/absuser/repo.git

验证添加偏僻的
$ git remote -v

$ git config --global user.email "[email protected]"

$ git config --global user.name "username"

$ git add .

$ git commit -m "my first comit "

$ git push origin testbranch

现在你的代码已经推送到 git 上了。

如果其他人也在同一分支上提交了代码,并且您想要将所有更改与本地计算机上的代码合并并推送到 git,请按照以下步骤操作:

首先,您必须标记所有更新的文件。

$ git add .

$ git pull origin testbranch

如果发生任何冲突,请解决该冲突并执行以下步骤,

$ git add .

否则继续

$ git commit -m 'merged changes from master'

$ git push origin testbranch

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.

$ cd /home/orange/Documents/code

$ git init

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

$ git config --global user.email "[email protected]"

$ git config --global user.name "username"

$ git add .

$ git commit -m "my first comit "

$ git push origin testbranch

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 .

$ git add .

$ git pull origin testbranch

If any conflict occurs then resolved that and do following steps

$ git add .

otherwise go ahead

$ git commit -m 'merged changes from master'

$ git push origin testbranch
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文