3

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

Snifkes
  • 133
  • 1
  • 6
  • check what are the commits on remote server and then use `git log` to see commits in your local repo. Match both of them and then you will be able to figure out everything. If both of them are identical then you already have updated changes from the remote server – Arpit Solanki Jul 13 '17 at 14:20
  • I did. Whenever I use pull or fetch (which I presume perform updates), I do not see the changes in the local repository, using 'git log'. it will just show me the last commit I cloned. – Snifkes Jul 13 '17 at 14:34
  • 1
    Do not clone with `--depth` if you want to *use* your clone. Please [check out the Git Book](https://git-scm.com/book/en/v2/) to learn how to exchange changes properly with remote repositories. – poke Jul 13 '17 at 14:38

1 Answers1

1

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.

torek
  • 448,244
  • 59
  • 642
  • 775