Can the .git folder be outwith of the repository ?

I am using Sourcetree for Windows with IBM Notes.

When starting from a repository clone I need to add the source files into Eclipse. The problem I have is the older version of eclipse that i need to use has no filter capability so it imports the .git folder and then all sorts of weird recursion issues start as both Sourcetree and Eclipse want to manage the .git folder.

Can I put the .git folder somewhere else ? I have tried to use

=>mkdir somefolder

=>mv * somefolder

and then import the somefolder to eclipse but then in the repository the files are all in a folder called somefolder which causes other confusion.

So -- is it possible to have the .git folder outwith of the repository ?

Thanks

1 answer

0 vote

Hi Sean,

This can be done, by running a command similar to this:

git --git-dir=../repo --work-tree=. add foo

This, however, is not a good idea because you'd need to specify it with every git command you ever use.

You can also export GIT_WORK_TREE=. and GIT_DIR=../new_location and Git will pick them up on each command. That will only allow you to work in a single repository per shell, though.

I think your best option is to symlink the .git directory to somewhere else, or creating a symlink to the .git directory from the directory you've chosen.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published 4 hours ago in Summit

Networking, learning, and lightsabers: Daniel Eads top reasons you can't miss Summit Europe 2018

As a Support Engineer at ITHAKA, @Daniel Eads spends his days administering Jira and Confluence to help his team work better together. He is also a Community Champion, an AUG leader, the list goes on...

71 views 2 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you