3

I have recently tried using Bitbucket for the first time. I was hired onto a project which up until now has had no version control. This made me nervous so I convinced my boss to let me upload it. My problem is this: Instead of just adding the folder in which I initialized my git repo, Bitbucket seems to be adding the parent directory and all the files in it. My project structure is like this:

User/Documents/Work/CompanyName/Project

I ran git init in Project but when I pushed to the remote, it seems to have pushed all the files in CompanyName as well. I have tried deleting both the repo and my local folder and doing it over again but I always end up with the same problem. Is this normal?? And is there anything I can do to stop it from happening again, other than moving all my files?

Edit: Okay something weirder than I thought is going on, because I deleted the existing Project directory and made a new one:

User/Documents/Work/Project

But when I pushed to Bitbucket it insisted that project is still in CompanyName/Project, even though that directory doesn't exist anymore. Think there's something wrong with my git, going to try clearing it out.

lucky3
  • 53
  • 1
  • 9
  • Are any of the parent directories git repos? – Dai Aug 19 '18 at 17:09
  • No, my other repos are self-contained in their own unrelated directories. I've checked the parent directories using git status and none of them are git repos. – lucky3 Aug 19 '18 at 17:14

3 Answers3

0

If you are certain no parent folder has its own .git/ subfolder, then you can try again:

cd User/Documents/Work/CompanyName/Project
git init .
git add .
git commit -m "Add all files"
git remote add origin https://bitbucket.org/<aUser>/<aRepo>
git push -u --force origin master

Check your environment variable for any GIT_xxx variables.
(GIT_DIR could be set to User/Documents/Work/CompanyName for instance)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

So I think the problem was that after I deleted my remote repo, I made a new one with the same name, and either the files hadn't been deleted off Bitbucket's servers yet or Bitbucket tried to recover them for me. Whatever the case, the problem was solved after I cleared out my git's cached files and created a new Bitbucket repo with a different name.

lucky3
  • 53
  • 1
  • 9
0

I had the same issue. I found out that ".git" folder was in the parent folder while I was expecting it to be in the current folder. I just cut&pasted the .git folder from parent folder to the child (current) folder and added, committed, pushed without a problem.

alercelik
  • 615
  • 7
  • 11