Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: how to sync to latest revision

Tags:

git

Warning: git novice here.

I have downloaded the source code of an open-source project (ffmpeg, to be exact) using git (git clone). I checked out an older revision in order to do test it (git checkout [version number]), and git told me that I'm now in a detached HEAD state. Now I want to resync again to the latest remote revision, but I don't know how.

I don't want to create any local branches. I haven't made any local changes that I want to keep. I don't want to do any of those fancy things that git can do when you are a serious developer (which I'm not). I just want my local source tree to be the same than the latest remote version.

git checkout . doesn't do anything. git pull tells me that I'm not currently on a branch. Short of erasing everything and do a git clone again, what else can I do?

like image 823
PaulJ Avatar asked Sep 14 '12 13:09

PaulJ


1 Answers

I don't want to create any local branches.

Sure you do. You just want a "local tracking branch", which is a branch that tracks a remote branch, making it easy to stay up to date with the project.

Try this:

git checkout master ;# you should have a 'master' branch by default
git pull ;# to get the newest changes from the remote repo

Issue git pull on that branch anytime you want to stay up to date with the remote. You can see how local tracking branches are configured using git remote show origin, and I strongly recommend spending a little time in the git-scm docs even if you don't want to do fancy git stuff. A little background knowledge will help you navigate that source tree nearly any way you want.

like image 171
Christopher Avatar answered Nov 10 '22 14:11

Christopher