![]() ![]() # each one has an index find the one before you broke everything # you will see a list of every thing you've Oh shit, I did something terribly wrong, please tell me git has a magic time machine!?! git reflog So here are some bad situations I've gotten myself into, and how I eventually got myself out of them in plain english. Git documentation has this chicken and egg problem where you can't search for how to get yourself out of a mess, unless you already know the name of the thing you need to know about in order to fix your problem. Thanks! (I know, I'm a git newbie, please forgive!).Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. Checked git diff master.origin/master so there weren't any differences and that's it. I just forced push to origin, without even specifying what commit I wanted to force on master since in this case it's whatever HEAD is at. I didn't even need to reset -hard, my current commit was OK. So I didn't checkout master locally because I already was after a commit. Later I kept amending my local master branch and when I decided it's time to push again, I was faced with different master branches and found out I can't amend origin/upstream ( duh!) like I can local development branches. One late night, in paranoid fear of loosing my progress to hardware failure or something out of the ether, I decided to push master to origin. So I decided to work locally by amending my last commit every time I wanted to save my progress on the main branch (I know, I should've branched out, committed on that, kept pushing and later merge back to master). Since I had a similar situation, I thought I'd share my situation and how these answers helped me (thanks everyone). How can I fix this issue? The things that I'm looking for is Head of local/master and origin/master point to same commit. Since, I reset the head of origin/master I expect local and origin should be in same direction but as you see, git is saying that my local/master is behind origin/master by 7 commits. ![]() ![]() (use "git pull" to update your local branch) Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. $ git commit -m "Reverting to the state of the project at e3f1e37"įinally, I checkout to my local master. Then I tried to add commit to origin/header that I was not successful. HEAD is now at e3f1e37 development version code incremented for new build. its okay now.Īnd reset the header by this command: $ git reset -hard e3f1e37 If you want to create a new branch to retain commits you create, you mayĭo so (now or later) by using -b with the checkout command again. State without impacting any branches by performing another checkout. You can look around, make experimentalĬhanges and commit them, and you can discard any commits you make in this Since I want to reset origin/header as well, I checkout to origin/master: $ git checkout origin/master Nothing to commit, working directory clean # (use "git pull" to update your local branch) # Your branch is behind 'origin/master' by 7 commits, and can be fast-forwarded. When I enter $ git status command, terminal says: # On branch master I reset my local master to a commit by this command: git reset -hard e3f1e37 ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |