2

I accidentally selected my project's Git folder to be

e:\programs\trimetric game\trimetric game

instead of one folder up, being

e:\programs\trimetric game

I want to move the Git repo to be contained in the previous folder, since Visual Studio tracks Git but only when it is in that folder. I am uncertain of how to do this, while still preserving all my previous commits as if they happened in the hierarchically higher folder.

Also, this project is on GitHub and I am unsure if these changes will affect that or not.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user975989
  • 2,578
  • 1
  • 20
  • 38
  • Possible duplicate of [Moving a git repository up one hierarchy level](https://stackoverflow.com/questions/5408475/moving-a-git-repository-up-one-hierarchy-level) – feeela May 02 '18 at 09:15

1 Answers1

1

edit because the comment shows I misunderstood the question at first

First: as long as you don't delete a remote branch (or push -f, which is basically the same), your github repo is safe: you won't loose data.

Now, to do what you want, you could:

cp -r "e:\programs\trimetric game" "e:\programs\trimetric game.backup" #better safe than sorry
cd "e:\programs\trimetric game\trimetric game"

#Start to make the repo look like what you want
mkdir "trimetric game"
git mv * "trimetric game"
cp -r ../* .
git add . #Add to git those files we've just added
git commit -am "Changing the structure of the repo"

#Now move it up
#We could use mv, but here is a simpler approach
git push origin master #or work with another branch if you don't want to change master now
cd ../..
rm -rf "trimetric game" #We delete everything because we've backed up everything on github
git clone "https://github.com/xxx/trimectric game" 
gturri
  • 13,807
  • 9
  • 40
  • 57
  • I meant that I would like git to monitor "e:\programs\trimetric game" rather than the folder within it, but not to move anything inside. – user975989 Jul 14 '14 at 20:24
  • Then I misunderstood your question. I edited my answer consequently. – gturri Jul 14 '14 at 21:44