B
B
beduin012015-01-20 09:08:17
git
beduin01, 2015-01-20 09:08:17

How to pull revision from github?

The situation is simple. I've committed the code fix to the repository. Then I edited the code and decided to roll back to that committed version. Doing a git pull -- System says "everything is up to date". I suspect because I haven't committed any of this code yet.
How can I just roll back to the previous state without making this commit?
And how is fetch different from pull?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Askar Familiev, 2015-01-20
@beduin01

... I decided to roll back to that committed version.

if you haven't made any other commits since the last commit, and you need to bring the files in the working directory to the state of the last commit, then it's enough to do this:
this command will remove all your changes that you have made. Be careful! Before doing that, it's better to do
will save your changes from the working directory. In the future, you can pull them out from there with the git stash apply command for each command, it is better to read the documentation git stash --help git chechout --help option --help will display the full documentation for the command , I recommend reading the documentation in Russian on this site
if you need to rollback to a specific commit, then also use git checkout , here is a piece from the documentation
where commit is the hash code of the commit, it can be seen through git log
the best practice is to use branches - branch everything is fine here

V
Victor, 2015-01-20
@v_decadence

git pull = git fetch + git merge
That is, pull is getting new data from origin (fetch) and merging it with the current branch. fetch simply fetches new data (commits), but doesn't merge it into the current local branch.
Rollback to the previous commit (if you did not commit unnecessary changes, that is, resetting the changes): git checkout HEAD . (dot - part of command)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question