-1

I created a new repo and ran the following commands:

git add folder
git commit -m 'commit'
git remote add origin 'https://github.com/User/newrepo.git
git push origin master

However, when I checked the files on github, somehow other files appeared together with 'folder'. I may have forked those files or pulled them from someone else's github account previously. What is the problem here? How do I resolve this?

user3918985
  • 4,278
  • 9
  • 42
  • 63

2 Answers2

0

If you're sure the files shouldn't be there, pull the repo, remove the files, commit, and push back.

git pull origin master
rm extra_files
git rm extra_files
git commit -m "removed extra_files"
git push origin master
Toam
  • 1,000
  • 1
  • 7
  • 12
  • yes I can do that to solve the problem but I want to know why so that the problem doesn't come up in future. I didn't have this problem of extra files appearing before. – user3918985 Aug 17 '14 at 03:19
  • What is the output from git log? It should provide some insight into where the files came from and who added them. – Toam Aug 17 '14 at 03:21
  • http://stackoverflow.com/questions/2389361/undo-a-git-merge should be helpful. Depending on how far back the merge happened and how large the repo is it might be a bit of work to get all your expected files back to the current version. – Toam Aug 17 '14 at 03:26
  • I just want to undo the merge by default so maintaining the version doesn't bother me. My project is new and I don't mind creating a new repo for it. It's just that I can't seem to remove this auto merge. The answers online talk about maintaining your current version while undoing the merge but I'm not concerned about that. – user3918985 Aug 17 '14 at 03:47
  • I would suggest a new, more specific question based on your updated understanding of the problem. – Toam Aug 17 '14 at 07:18
0

Fixed the problem.

I ran a rm -rf .git in the parent director of the folder and re-initialized git in the folder.

user3918985
  • 4,278
  • 9
  • 42
  • 63