森口万太郎
森口万太郎

Reputation: 895

I'm not sure if the HEAD of the local repository is at the latest point of the main branch

I'm new to using Git and I'm not sure about the current situation.

enter image description here

At the moment, it is in the above state. I've been able to "fetch" from a remote repository and open and run the latest state in my local VS Code, but does that mean that my local HEAD is at f52a6e9a at this point?

If so, I want to bring the local HEAD to the latest point of the main branch, but I don't know how.


2022/7/10/15: 06 Addendum git switch main After executing, the following status is displayed. I think you can now move to the main branch, but at this point the HEAD is at f52a6e9a, right?

enter image description here


Then I executed "git checkout 17d73f6b63ca50e78d3a5a80339b6e8e037cc933". Then, it became the following state.

enter image description here

This is what I want because HEAD is at the latest point of main branch.

As you may have noticed, this is something I'm doing experimentally to study git / Github, and I think I have a lot of basic things to learn.

Upvotes: 2

Views: 50

Answers (1)

VonC
VonC

Reputation: 1323793

Simply check your git status in a terminal (even from VSCode)

That will confirm where HEAD is.

A git switch main would be enough to bring your local repository to that local branch.
From there, a git pull would update it to origin/main if you want.

Avoid git checkout, which is confusing.
And do not checkout a commit, which leads to detached HEAD.

To go to 17d73f6 (the commit or origin/main):

git switch main
git pull

Upvotes: 2

Related Questions