Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to run "git pull" after "git clone"?

Tags:

git

I have seen a few people running:

git clone <url>
git pull

I personally only ran git clone <url> for all the projects are worked for.

I read in the documentation this:

   After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).

but it didn't really give me a reason for it.

My question is: What is the added value of git pull when I just cloned the project a second ago? Should I always run a git pull as well after git clone <url>?

Thanks

like image 440
Mihai Avatar asked May 01 '19 19:05

Mihai


2 Answers

The answer is "it depends". How long did it take to clone the repo? Do you think someone has made additional commits since you cloned it? If the answer to that is "yes", then pull.

If the clone took 5 seconds, it's not likely. If it took 30 minutes, maybe.

There's no harm in doing a pull immediately after a clone.

like image 190
Daniel Mann Avatar answered Nov 20 '22 13:11

Daniel Mann


My question is: What is the added value of git pull when I just cloned the project a second ago? Should I always run a git pull as well after git clone ?

It ensures that your code is the most up-to-date prior to you working on it. I get into the habit of running git pull prior to working on any new development as a sanity check to make sure no other developers pushed any code.

If the clone took a second and you start working on it immediately- its virtually unlikely that there will be any changes you missed. But its still a good habit to make sure you have the latest changes, even if you're reasonable sure you're up-to-date.

like image 35
chevybow Avatar answered Nov 20 '22 12:11

chevybow