Hailwood
Hailwood

Reputation: 92581

Adding project back under git control?

So, I have a project that was originally under git version control, The project has since had all git related files removed (afaik).

So when I try to add it back under version control (using PHP Storm) I get told that

Some configured Git VCS roots are not under Git or have Git repositories in subdirectories without configured VCS root

Which I am assuming means there is still a trace of git left in there somewhere.

I am using ubuntu so I cd'd to the root directory, then did ls -Ra | grep .git but nothing showed up. so what am I doing wrong? where could the git stuff be hiding?

and, once I remove it, how do I add this project back into git control? is there other than choosing the right repo that I will need to do?


After a bit of research I came across this article which seems to say that phpstorm looks to your resource root instead of project root for the version control info.

Now my structure is

/unity/nz <- under it's own version control
/unity/au <- trying to add to version control

So this could be the problem..

So maybe i'll do this without php storm, so my second question still stands, How do I add this back under version control in the same repo (terminal commands would be useful!)

Upvotes: 2

Views: 311

Answers (1)

Nic
Nic

Reputation: 13733

From the au directory, you're just going to repeat the repo "init" process we went through in the comments.

git init

Now you've got your repository. You've got two options here; either add files for tracking, or setup your .gitignore file to start ignoring things that you don't want in your repository. I usually setup .gitignore first. You can open it in a text editor and fire away.

After that, you add the .gitignore with the following:

git add .gitignore

and commit with:

git commit -m ".gitignore in place"

With that in place, you can type:

git add .

Which adds all of the files in the au directory (and subdirectories) for tracking. It'll check the .gitignore file first and not include those files for tracking.

You can type git status at any time to get some useful information about what you're currently doing. You'll need to commit the files you added:

git commit -m "initial commit"

And now you're tracking them, so when you save from PHP Storm, you can go back to the terminal and type:

git status

This will show you the file that you changed. You can add it (or, if you've made changes to x amount of files, you can add those too) with the git add . command. Commit with a helpful message and you're good to go.

At this point, you can setup your github repo as a remote. More info on that here. Once you've done that, you can push the current history to github:

(assuming empty remote)

git push remote master

I see you're working on something web related, so I suggest you take a look at this post for using a branching model. This helps a lot. If you practice this, I think you'll prefer it to working with a client or any other method :)

Upvotes: 1

Related Questions