Aditya Hadi
Aditya Hadi

Reputation: 384

Error when running git pull origin master

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

Upvotes: 2

Views: 33791

Answers (6)

ritesh9984
ritesh9984

Reputation: 418

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

Upvotes: 0

user3190254
user3190254

Reputation:

 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

Upvotes: 1

WhiteHawk
WhiteHawk

Reputation: 89

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

Upvotes: 0

hd1
hd1

Reputation: 34657

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

Upvotes: 0

user173973
user173973

Reputation:

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

Upvotes: 2

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.

Upvotes: 4

Related Questions