amok
amok

Reputation: 1745

How to keep the GIT repos in sync

I don’t grasp GIT yet. So I have a basic question:

I want to keep one of the repos that I am using (I don’t own it, I cloned it) in sync with my local copy.

How do I do that?

I am aware of git fetch/pull but when I do run that in the same folder where I executed git clone http://.....git I get the following error

fatal: Not a git repository (or any of the parent directories): .git

Thanks, mE

Upvotes: 9

Views: 19317

Answers (3)

Ilya Ivanov
Ilya Ivanov

Reputation: 2499

Git clone creates a new directory for cloned repo. You need to go into it first. For example:

$ git clone git://github.com/git/hello-world.git
$ cd hello-world
$ git fetch

Upvotes: 3

markdorison
markdorison

Reputation: 148644

git fetch will retrieve all changes from the remote.

git pull will merge those changes from the remote into your local copy (this accomplishes two commands in one step. fetch & merge

If you have commit access to the remote repository, git push will push your local changes to the origin that you cloned from.

Upvotes: 12

Miles Strombach
Miles Strombach

Reputation: 308

Git fetch will download all of the changes that exist on the remote, but won't update your working tree. Git pull will download changes and if you're on a local branch tracking a remote branch, will update it for you.

Upvotes: 0

Related Questions