1

I'm very new to git. My issue is that I have project on github, near my repo folder I created a .rar archive, and then by mistake made commit and then push to master branch. And now my github project looks like:enter image description here

And I can't access my VRP folder on github. It must look like: enter image description here Sorry for so stupid question, but i'm very new to git, and don't want to create new git for my project. How to fix it? UPDATED: enter image description here

Andrew
  • 423
  • 1
  • 6
  • 16

2 Answers2

0

I suggest to reset to a previous sane version of your project and force push it on Github. The process explained:

Locally, find the hash of the commit you would like to revert to. There are a number of options for you, some of them are:

git log

or

gitk --all 

or

git reflog

let's say you'd like to restore hash 12345, then:

git checkout master
git reset --hard 12345
git push origin master -f
Sébastien Dawans
  • 4,537
  • 1
  • 20
  • 29
  • didn't helped ;( (Total 0) – Andrew May 22 '15 at 22:49
  • can you be more specific? Total 0 what? – Sébastien Dawans May 22 '15 at 22:55
  • that log message is normal, it means there were no new objects to transfer - that's expected since all the data needed to define that tree already exists on the remote, you're just moving a branch to a previous revision. If `f3adccb` is the correct commit then you are done – Sébastien Dawans May 22 '15 at 23:09
  • I visited your repo and seems like it's what you wanted: https://github.com/litwisha/finalize – Sébastien Dawans May 22 '15 at 23:09
  • it's not that repo. it must be: github.com/litwisha/VRP . I don't quite understand why it use finalize repo, not VRP. in e\VRP folder must be VRP repo... that's interesting – Andrew May 22 '15 at 23:11
  • well your remote currently points to https://github.com/litwisha/finalize.git. If you want to push to https://github.com/litwisha/VRP.git you'll have to define it as remote. `git remote set-url origin https://github.com/litwisha/VRP.git` – Sébastien Dawans May 22 '15 at 23:15
  • A more general comment is that you have to define what you'd like your repository structure to be. Why do you have 2 repositories? If that's intentional, do you intend to have one as a submodule of another? Seeing you're new at git I suggest you keep it simple. – Sébastien Dawans May 22 '15 at 23:16
  • can I replace whole project? – Andrew May 22 '15 at 23:22
  • Do you mean delete a project? Now that both your repositories are in the same state you can delete one of them in GitHub. I would also reclone a new copy of the remaining project in a fresh directory on your drive to make sure you're not in some nested projects – Sébastien Dawans May 22 '15 at 23:30
  • Sometimes, when I push project, not all my files are changed in repo. So what if I want all changes to be in my repo? git push origin master -f will replace fully replace my project? – Andrew May 22 '15 at 23:33
  • New files are untracked until you explicitly stage them (`git add`) and commit. Use `git status` to see such things. Please open new questions because we are diverging from the initial post. Have fun with Git. – Sébastien Dawans May 22 '15 at 23:36
0

You can undo a commit. How to undo last commit(s) in Git? has a guide on how to undo a commit. Basically you need to git reset HEAD~1 but for more details go to the link or Google git reset

Community
  • 1
  • 1
NendoTaka
  • 1,224
  • 8
  • 14