Carol.Kar
Carol.Kar

Reputation: 5345

Git - The following untracked working tree files would be overwritten by merge:

I am using git version 2.17.1.

When using I get git pull origin master --allow-unrelated-histories:

root@root-VirtualBox:~/Desktop/Code/project git pull origin master --allow-unrelated-histories
Username for 'https://github.com': acc_nt
Password for 'https://[email protected]': 
From https://github.com/acc_nt/demo_project
 * branch            master     -> FETCH_HEAD
error: The following untracked working tree files would be overwritten by merge:
        ...
Aborting

However, my current settings look like the following:

root@root-VirtualBox:~/Desktop/Code/project# git status
On branch master
nothing to commit, working tree clean
root@root-VirtualBox:~/Desktop/Code/project# git branch
* master
root@root-VirtualBox:~/Desktop/Code/project# git stash
No local changes to save

Any suggestion how to pull & merge.

Appreciate your replies!

Upvotes: 1

Views: 5531

Answers (1)

VonC
VonC

Reputation: 1323263

--allow-unrelated-histories is an option of git merge (called by git pull), used to merge histories that do not share a common ancestor.

Hopefully, in your case, this should not be needed, considering your local cloned repository and its local master branch should have a common history with origin/master.
So a simple git pull should be enough. Then git push.


You can use that option when:

  • you have created a GitHub repository initialized with a README.
  • you have create (git init) locally a repository with a README (and other files)
  • you want to push for the first time.

In this case:

  • make sure git status is clean

  • use:

      git pull --rebase=merge --allow-unrelated-histories
    

Upvotes: 1

Related Questions