Snifkes
Snifkes

Reputation: 133

Do I have to use git clone every time?

I am kind of new to Git and I am not sure how to work with it.

Currently, I have a git in a remote server. I am trying to connect my computer to this git repository. From what I have read online, it is best to use clone for this purposes. Now, I have made some changes in my repository on the remote server. I would like to update them on my own computer.

I have tried to use pull but it did not seem to do anything. I have tried fetch and still nothing.

It is only when clone the repository again that I have seen those changes. I am sure that git can just update my repository instead of having to recopy the whole thing. Thus, my question is:

Do I have to clone the git every timee time to receive changes done on the repository?

Here are my commands:

On remote git repository:

  1. peform changes
  2. git add -A
  3. git commit -m "message"
  4. git push master origin

On my own computer:

  1. git pull <server information> - does not update changes
  2. git fetch... - no update
  3. git clone --depth=1 ... - downloads the current state of the git.

To make it clear: how can I just update my computer's git rather than redownloading the current git state every time?

Thanks

Upvotes: 3

Views: 6498

Answers (1)

torek
torek

Reputation: 489273

As poke said in a comment, you will want to avoid using --depth 1 if you plan to actually use your repository. The --depth option, which also implies --single-branch by default, is mostly intended for "get me just this one commit because I'm going to just use the one commit and then throw away the repository entirely".

It is possible to use --depth plus --no-single-branch to get a limited subset of history into a shallow clone, and then do some work on that shallow clone, but it's quite tricky. See How to update a git shallow clone? for all the gory details.

Upvotes: 1

Related Questions