I have did a checkout and the crontab did an entry in one file. I have commited the changes withouth push. Now I want to go back to the last comit before the checkout. Anyone knows how exactly to do this?
            Asked
            
        
        
            Active
            
        
            Viewed 31 times
        
    1 Answers
0
            
            
        git reset --hard origin/master
This assumes your remote repo has the default local ref origin, and you are on the master branch. To check this you can run git branch -r and you should see something like origin/HEAD -> origin/master as one row in the result.
As the comments rightly point out, the --hard option is going to irrevocably remove any local changes. Be sure this is what you want to do.
 
    
    
        gingerbreadboy
        
- 7,386
- 5
- 36
- 62
- 
                    Be VERY careful of using `reset --hard` it is difficult recover from this if you loose information – Liam Nov 10 '20 at 14:20
- 
                    HEAD is now at 1ffbdf0 commit to checkout. I did commit I did not stash the changes. Yes on origin/master – Robert-Dan Nov 10 '20 at 14:21
- 
                    [This difficult](https://stackoverflow.com/a/5788069/542251) @Robert-Dan – Liam Nov 10 '20 at 14:22
- 
                    On the Git server the data is still there right? – Robert-Dan Nov 10 '20 at 14:22
- 
                    Not if you didn't push it no – Liam Nov 10 '20 at 14:23
- 
                    Depends on what you mean by "Git server the data " – Liam Nov 10 '20 at 14:24
- 
                    I did pull but is the same last commit – Robert-Dan Nov 10 '20 at 14:27
- 
                    "fatal: You are on a branch yet to be born" – Robert-Dan Nov 10 '20 at 14:34
- 
                    suggests there are no commits on your branch, ie master has no initial commit. Maybe. – gingerbreadboy Nov 10 '20 at 14:37
- 
                    I was lucky that there was still the hashes on the Terminal at the last changes (commits). It was enough to write: git reset --hard 3aabb82 – Robert-Dan Nov 10 '20 at 15:55
