Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to revert to changes I committed?

I am using beanstalkapp and i see conflict in front of a branch, just conflict isn't very helpful. But even when i do git status, i don't see anything which says there is a conflict. Any help to find where can i find the files being conflicted? Here is a image from dashboard

like image 300
localhost Avatar asked Apr 19 '16 14:04

localhost


1 Answers

If you see conflict on the server side but you don't see it on your side - you might have a different content. First of all do a git pull from the remote server to be sure you are up to date.

i want to go back to a commit, couple of days back and discard anything after that

Read out this full detailed answer which will explain in details whats exactly you can do.

Basically you have several options but the main options are:

  • git reset
  • git checkout -b <sha-1>

How to find out the required commit?

You can do it with the log command or with the git reflog

git reflog

git reflog will display any change which updated the HEAD and checking out the desired reflog entry will set the HEAD back to this commit.

Every time the HEAD is modified there will be a new entry in the reflog

# print teh git reflog
git reflog

# find out the desired commit (of the index in the reflog) 
git checkout HEAD@{...}

enter image description here


git checkout

# Find out the desired commit which you wish to go back to 
# Once you have it checkout the commit to a new branch
git checkout -b <new branch> <commit_id>

Another option is the git reset

git reset HEAD --hard <commit_id>

"Move" your head back to the desired commit.
As before find out the desired commit and then tell your repository to point on this commit.

# read the documentation about the different flavors of the reset (hard/mixed/soft)
git reset HEAD --hard <sha-1>

And now your repository is "back" to the desired commit.

like image 152
CodeWizard Avatar answered Oct 19 '22 23:10

CodeWizard