Sublime Forum

Place .git in another folder

#1

My project is like following:

C:\ Projects \ A \ .git
C:\ Projects \ A \ .gitignore
C:\ Projects \ A \ [Project files]

I want to put the .git folder and .gitignore file in another folder. For example:

C:\ git \ Project A \ .git
C:\ git \ Project A \ .gitignore

C:\ Projects \ A \ [Project files without .git folder and .gitignore file]

How I can do it easily with Sublime Merge?

My git version: 2.25.1

0 Likes

#2

As far as I know this isn’t something git (and by association Sublime Merge) supports out of the box. You could achieve this using symlinks, but there would still be a .gitignore file and .git folder in your project directory.

0 Likes

#3

It works with GitExtensions, but not with Sublime Merge Build 1204.

Support for core.worktree was in Build 1084.

My structure:

C:\ project \ A \ [Project files]

C:\ git \ A \ .git [Folder]
C:\ git \ A \ .gitignore [File]

Command line

C:\ git \ A \ git config core.worktree C:/project/A
C:\ git \ A \ git config core.excludesFile C:/git/A/.gitignore

After that the C:\ git \ A \ .git \ config file looks like that:

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
worktree = C:/project/A
excludesFile = C:/git/A/.gitignore

Now I open Sublime Merge and see the changed/untracked files.

But, if I click on Stage I get following error:

fatal: not a git repository: ‘/C/git/A/.git’

In the Console I got 2 lines:

Executing: “C:\Users\blabla\Downloads\sublime_merge_build_1204_x64\Git\cmd\git.exe” “add” “–” “Hello World.txt”
Working dir: C:\project\A

Maybe the reason is: /C/

Why is it not:

C:/git/A/.git

With Command line it works:

PS C:\git\A> git status
On branch master

No commits yet

Untracked files:
(use “git add …” to include in what will be committed)
Hello World.txt

nothing added to commit but untracked files present (use “git add” to track)
PS C:\git\A> git add “Hello World.txt”
PS C:\git\A> git commit -m “initial”
[master (root-commit) e2c7185] initial
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 Hello World.txt
PS C:\git\A>

Here I added a new file and clicked stage:

1 Like

#5

you can also do it manually? no? there is exactly the same function I saw
try to look more closely

0 Likes

#6

@JojoKalma71 with Command line it works, see above.

0 Likes

#7

Thanks for reporting this. It was indeed a bug with the git path not being converted from our internal format to the native one. This only affects windows. We’ve got a fix for this.

0 Likes