1

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!

6
  • 2
    Those files are tracked in the branch that you are merging, that's what git is trying to tell you.
    – eftshift0
    Dec 17, 2020 at 19:30
  • 1
    What is your use-case? Why do you need the --allow-unrelated-history?
    – triplem
    Dec 17, 2020 at 20:49
  • @eftshift0 Yes, but I cannot push anything to the master branch
    – Carol.Kar
    Dec 17, 2020 at 20:55
  • @triplem I simply want to push/pull my files from the master branch, even though they might be the same
    – Carol.Kar
    Dec 17, 2020 at 20:55
  • If the files are the same (after a clone) you can just "pull" without any additional parameters. Push willl fetch all changes from the remote repository and merge the changes into your local workspace. If there are no changes, nothing will happen anyways.
    – triplem
    Dec 17, 2020 at 21:01

1 Answer 1

1

--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
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.