I am trying to set up a git repository using a manually set working line with:
cd /Users/braitsch/repos/project1 git --git-dir=. --work-tree=/Users/braitsch/projects/project1 init
After running above, I can add the files located in "/ Users / braitsch / projects / project1", through: git add the file somefile or git.
Commits are working fine, like calls to the "git branch"
However, git stash list throws the following error:
fatal: /usr/local/Cellar/git/1.7.4.4/libexec/git-core/git-stash cannot use without a working tree.
Is restriction supported in custom trees?
git config --local core.worktree echoes out : /Users/braitsch/projects/project1
Any thoughts would be greatly appreciated!
-------- -------- UPDATE
As @jleedev noted below, an error occurs when trying to call "git stash" from outside the working line. However, my workaround is to simply write cd to the working line and then call stash before going to the path to gitdir. Inconveniently, I know, but for the stash command the following actions are performed:
git --git-dir="projects/proj1/.git" stash list
This problem does not seem to contain other foreign stock commands, such as add, commit, branch, etc. Just as far as I can tell, "hide."
If you want to separate from the default structure when your .git folder is nested inside your working line, you can find the following steps:
- create the directory where you want to save the git repository
- Create a directory in which you want to save the files that you want to track. (both of them can be anywhere in your file system)
cd to the git repository folder and run:
git --git-dir=. --work-tree="path-to-your-project-folder" init
This will launch a new repository and link it to its external working folder folder.
To run the standard add, delete, branch, commit, cd commands in the git repository and run your command as usual. However, to run stash, be sure to run cd in your working folder , and then run stash, as I noted above, preceding the command using the path to your gitdir.