0

I have several Github repositories cloned on my computer. They are not my projects but rather other people's programs I like to use.

I usually use git clone url to download a repository to my computer. To keep the source code or program updated, do I need to use git clone url all the time for each program (and whenver I see any change in the repository)? Or is there a simpler way to keep every repository I cloned from Github updated?

I'm looking for some command like brew upgrade just as homebrew upgrades all the packages downloaded automatically.

Thank you very much!

clay45
  • 5
  • 4
  • 4
    `git pull` is probably what you're looking for. – tkausl Feb 17 '19 at 23:11
  • 1
    https://stackoverflow.com/search?q=%5Bgithub%5D+update+local+repository – phd Feb 17 '19 at 23:43
  • 1
    This is very basic Git usage. Please find a Git tutorial and go through it carefully. If that doesn't do it, before asking a question, please search for existing questions. See [ask]. – ChrisGPT was on strike Feb 18 '19 at 00:26
  • Thanks for the comment and sorry for the duplicate question. I did search quite a lot and read a few posts before asking this question - but since I'm a beginner I couldn't understand very well. Most questions I found were about their own Git repository so I wasn't sure if it works the same for other people's repository. Anyway, thanks for the help! – clay45 Feb 18 '19 at 02:49
  • Also, I wanted a command or package that updates all repos and it seems like I found one: https://www.npmjs.com/package/git-pull-all – clay45 Feb 18 '19 at 02:50

1 Answers1

0

You don't need to run git clone all the time; you can actually pull each time to get changes. Better still just fork the repository and set an upstream to the project - yours will be in sync and you will get the updates whenever the owner of the repo updates it, and the owner gets his/her reps in the number of forks.

To set an upstream to a forked repo:

  • Navigate to the repository

  • under the repository name click clone or download

  • In the clone with HTTPs section, click the copy URL for the repository

  • open git bash

If you type git remote -v and press enter you will see the current configured remote repository of your fork.

  • Now type git remote add upstream the-url-you-copied-in-the-step-above then press enter.

That will keep your forked repository in sync with the original project

  • To verify the new upstream that your project is now synced type git remote -v in you git bash again. You will see the URL for your fork as origin and the URL for the original repository as upstream. Meanwhile if it was a forked project you will see the URL or the original repository as origin and upstream.
tripleee
  • 175,061
  • 34
  • 275
  • 318
Monday A Victor
  • 441
  • 5
  • 16