Solution:
The problem is that you are not folowing the files locally however identical files are follwed remotely so in order to "pull" your system would be forced to overwrite the local files which are not version controlled.
Attempt running
git add *
git stash
git pull
This will follow all files, dispel all of your local changes to those files, and then find the files from the server.
You can attempt command to clear the untracked files from the local
Git 2.11 and newer versions:
git clean -d -f .
Older versions of Git:
git clean -d -f ""
Where -d
can be replaced with the following:
-x
ignored files are also dispel as well as files unknown to Git.
-d
dispel untracked directories in addition to untracked files.
-f
is necessary to force it to run.
The only commands that performed for me were:
git fetch --all
git reset --hard origin/{{your branch name}}
A replacement for git merge
that will overwrite unfollwed files
The comments below conduct 'FOI' for the 'files of interest', the files that
subsist in the donor branch,
do not exist in the taking branch,
and are blocking the merge cause they are present and untracked in your working directory.
git checkout -f donor-branch # replace FOI with tracked `donor` versions
git checkout receiving-branch # FOI are not in `receiving`, so they disapppear
git merge donor-branch # now the merge works
A replacement for git pull
that will overwrite unfollwed files
pull = fetch + merge
, hence we do git fetch
followed by the git checkout -f, git checkout, git merge
trick above.
git fetch origin # fetch remote commits
git checkout -f origin/mybranch # replace FOI with tracked upstream versions
git checkout mybranch # FOI are not in mybranch, so they disapppear
git merge origin/mybranch # Now the merge works. fetch + merge completes the pull.
Elaborated explanation
git merge -f
does not exist, but git checkout -f
does.
We will employ git checkout -f
+ git checkout
to dispel the Files Of Interest , and then your merge can pass normally.
Step 1. This step perforce replaces untracked FOI with tracked versions of the donor branch (it also checks out the donor branch, and updates the rest of the working dir).
git checkout -f donor-branch
Step 2. This step dispels the FOI cause they they are tracked in our current (donor) branch, and inexistent in the receiving-branch
we switch to.
git checkout receiving-branch
Step 3. Now that the FOI are inesixtent, merging in the donor branch will not overwrite any untracked files, so we get no errors.
git merge donor-branch
Dispel all untracked files:
git clean -d -fx .