Git status collecting parent folder files

I just created a new project in htdocs/project , and when I use the status to collect files in this folder, it lists the files and directories contained in htdocs/project , but also lists all the folders and children of htdocs .

For instance:

 # Changes not staged for commit: # modified: ../otherproject/index.php # modified: ../project3/index.php # Untracked files: # ../otherproject/blah.txt # ../project3/img/lol.jpg 

If this helps, I used the Git Bash Here> option to change the Git directory to htdocs/project .

+4
source share
3 answers

Is htdocs repo git itself?

 ls htdocs/.git 

If so, this will explain what you see - there can be no other repo in the git repository.

(Sent as an answer, not a comment, because I don’t have enough persimmons.)

Edit: Based on the discussion below, this seems to be the problem. According to http://progit.org/book/ch6-4.html :

 Making a Subdirectory the New Root Suppose you've done an import from another source control system and have subdirectories that make no sense (trunk, tags, and so on). If you want to make the trunk subdirectory be the new project root for every commit, filter-branch can help you do that, too: $ git filter-branch --subdirectory-filter trunk HEAD Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12) Ref 'refs/heads/master' was rewritten Now your new project root is what was in the trunk subdirectory each time. Git will also automatically remove commits that did not affect the subdirectory. 

I did not do this myself, therefore, I hope that someone who will will gain some impressions.

+4
source

git status always lists all the files in the repository with respect to your current position. This means your repository is in htdocs, not htdocs / project

0
source

From what I'm compiling, it looks like you want to have several git repositories, each of which represents a project, deployed side by side in what seems like a web hosting directory.

From a little experiment (and confirmation by other answers) it seems that you created the git repository in htdocs , and one of them does not exist in htdocs/project . There may or may not be a git repository in htdocs/otherproject and htdocs/project3 .

Assuming that the current htdocs repository htdocs not have a commit history that you want to keep, you can safely delete the htdocs/.git and create new repositories in the htdocs/project and other project directories.

Otherwise, if you want to keep a commit history, you have to work a little. I'll start by backing up the htdocs directory, just in case. From there I will remove all subdirectories from htdocs except the htdocs/project directory and add these changes to the index. Then I moved the contents of the htdocs/project directory to the root of the repository (before htdocs ) and add these changes to the index. Finally, I would delete the htdocs/project directory, change the change, and commit. Please note: if there are files in the htdocs directory whose names are the same as in the htdocs/project directory, you can save some headaches by making an extra commit before moving the contents of the htdocs/project directory. From there, you can simply rename htdocs to project , create a new htdocs directory and move project to htdocs . Finally, simply move the backup project directories to the new htdocs directory.

0
source

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


All Articles