Git-stash cannot find work tree

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.

+6
source share
3 answers

This is either an error in the behavior of the commands or an error report. Commands that require a work tree and are implemented as scripts 1 check its presence using this command:

 git rev-parse --is-inside-work-tree 

which will fail if you are not actually inside the working tree, contrary to what is implied in the error message. On the other hand, commands that are implemented in C call setup_work_tree , which is automatically chdir in the work tree. Is it safe to change the require_work_tree function in git-sh-setup to fit this, I don't know.

1. git-am.sh git-bisect.sh git-mergetool.sh git-pull.sh git-rebase--interactive.sh git-rebase.sh git-stash.sh git-submodule.sh

+5
source

Edit:

Try setting the GIT_WORK_TREE environment variable to point to a suitable folder.


Original answer:

It was an odd team. Try this instead. This is much simpler:

 mkdir yourRepo cd yourRepo git init .. edit some files git add . git commit -m "First commit" 
0
source

I came across this using git for windows . 1.8.3 via ConEmu.

My problem seems to be related to the display of the drive where the path on the C: drive was indicated to P:\

git recognized the path for the mapped drive as /p at the prompt, but the parameter for git config --local core.worktree returned P:/

I reset using git config --local core.worktree /p , which gave me P:/ as a new value, but this is a fixed value. He did not seem to like the capital letter.

Turns out I just had cd /c and then cd /p have a git notification that I entered the working tree directory. Not sure why git is sensitive to cd , but could not find that I was in the right place when the shell was initialized.

0
source

Source: https://habr.com/ru/post/887151/


All Articles