M
M
Maxim Smirnov2016-01-26 15:03:42
git
Maxim Smirnov, 2016-01-26 15:03:42

How to go to the latest commit in a branch?

What is the console command to update the current versions of files in a branch to the latest commit?
The documentation suggests using the git pull command - download all changes from update the files to the latest version.
But the problem is that I'm using jgit - it's a script for Solaris (there are no official packages for git), and it doesn't have such a command.
There is a fetch command - but this is only for downloading from a remote change repository.
There is a reset --hard command - but for this you need to know the hash of the last commit.
What other commands are there in git besides pull?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
toxa82, 2016-01-26
@MaxiStyle

git fetch
git checkout <branch>
git merge origin/<branch>

R
Roman Makarov, 2016-01-26
@rmakarov

you can try git checkout HEAD, or do git logit, we will see the last commit, take the first 4 symbols of its cache - and then enter git checkout 1s24, where 1s24 are the same cache symbols

K
kkomissarov, 2019-06-06
@kkomissarov

A more universal way that allows you to go to any commit that is located in the branch later than the current one:
Display all commits in the branch, including those that were later than the current one:
And then just go to the last commit by hash:
And if it is the last one, then so (branch_name - branch name)
git checkout branch_name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question