tags:

views:

250

answers:

3

I am attempting to clone a git repository. The clone fails with the following message:

Untracked working tree file ... would be overwritten by merge.

I have run git clean on all of the branches; none have untracked files.
The file which is labeled untracked is only used in the branch I am currently working in and it is tracked.

Also, when I checkout the main branch and then checkout the branch I was originally working on, I the checkout succeeds but prints the name of the supposedly untracked file. Any ideas what this means?

Checking out files: 100% (477/477), done.

M       path-to-file-idenetified-as-untracked    
Switched to branch "Original_branch_name"

How can I get clone to work?

I have read about cloning. I am making a clone because I want to share this with someone else who doesn't currently have the reposoitory.

Here is what I entered, slightly edited. For example, I did several commands to cd, which are not shown.

$ git clone app.git clone/app.git
Initialized empty Git repository in /cygdrive/c/clone/app.git/.git/
error: Untracked working tree file 'C:/app.git/include/template/foo.xml' would be overwritten by merge.

$ git status
# On branch GT
nothing to commit (working directory clean)

$ git rm include/template/foo.xml
rm 'include/template/foo.xml'

$ git commit -m "Removed include/template/foo.xml because clone was failing with the message untracked working tree file would be overwritten by merge "
[GT]: created 77ca4ec: "Removed include/template/foo.xml because clone was failing with the message untracked working tree file would be overwritten by merge "
 1 files changed, 0 insertions(+), 89 deletions(-)
 delete mode 100755 include/template/foo.xml

$ git clone app.git clone/app.git
Initialized empty Git repository in /cygdrive/c/clone/app.git/.git/
Checking out files: 100% (522/522), done.

$ git commit -m "Added file deleted in previous commit after successfully cloning repository with file deleted"
[GT]: created f3eb7e8: "Added file deleted in previous commit after successfully cloning repository with
 file deleted"
 1 files changed, 89 insertions(+), 0 deletions(-)
 create mode 100755 include/template/foo.xml

$ git clone app.git clone2/app.git
Initialized empty Git repository in /cygdrive/c/clone2/app.git/.git/
error: Untracked working tree file 'C://app.git/include/template/foo.xml' would be overwritten by merge.
A: 

What version of Git are you using? And on What platform?

Depending on the OS, you may have some case-sensitive filename issue wich could bring this error message, as shown in this thread

I renamed CONTRIB/ChangeLog to CONTRIB/ChangeLog.old and tried again and this time it complained about contrib/README.
Are the errors because of something I did? I

I believe this may be caused by the fact that I have renamed CONTRIB to contrib.
On a system which has no distinction between upper and lowercase names, maybe this leads to a conflict?

Try removing the entire CONTRIB directory. If that fails, try to get a new clone of the repo.

This fixed it. Thanks.


But, once I added a copy of the file (which I need) and committed it, I tried to clone again and am back to the original failure message

That to me screams core.ignorecase set to true

core.ignorecase
If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like FAT.
For example, if a directory listing finds "makefile" when git expects "Makefile", git will assume it is really the same file, and continue to remember it as "Makefile".

The default is false, except git-clone(1) or git-init(1) will probe and set core.ignorecase true if appropriate when the repository is created.

Could you check if git config -l contains a core.ignorecase setting?

VonC
I'm using Windows with Cygwin. Git version is 1.6.1.2. I did rm the file and then committed. Then I tried to clone and that was successful. But, once I added a copy of the file (which I need) and committed it, I tried to clone again and am back to the original failure message.
Jennette
git config -l just shows my user name and user email
Jennette
A: 

The notification that the file is modified:

M       path-to-file-idenetified-as-untracked

means that you have local, uncommitted changes to the file in question (which is only tracked in the branch).

When you attempt to merge the branch into your master git is refusing to overwrite your uncommitted changes with the committed version from the branch.

Try committing the changes to your file on the branch before attempting the merge.

BTW, I assume you mean 'merge' and not 'clone' in your question. You should not be running 'git clone' on top of an existing git repository.

Frosty
Thank you for the suggestions. I can't commit the changes because none of my branches show uncommitted changes. I did mean clone, not merge. I am sending a clone of the whole repository to someone. When I run clone, it apparently does a merge. Why should I not be running 'git clone' on top of a git repository? When would one use 'git clone'?
Jennette
'git clone' is used to create a copy of a repository in a new location. Are there files in clone/app.git and clone2/app.git before you run your clone commands?
Frosty
A: 

git clone is for creating a new repository that is a clone of an existing repository; that is, it has all the same files, branches, and tags.

Once you have a repository, you generally want to use git pull to pull new changes down and merge them with your active branch, or git fetch to fetch changes into your remote tracking branches without merging them into your currently active branch (which could then be followed by a git merge if you decide that you do want to merge them in).

See the Git tutorial for an example of how to clone a repo and work with the clone.

Brian Campbell