Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fetch all git history after I clone the repo with `--depth 1`?

Tags:

git

There is a big repo with thousands of commits. When I clone it, I just want to see the latest code, and don't wait for too long, so I run:

git clone git://..../... --depth 1 

But later, I want to see all the history commits, but I don't know how to fetch all the histories.

like image 405
Freewind Avatar asked Mar 26 '15 02:03

Freewind


People also ask

What does depth 1 do in git clone?

Developers should be aware that the depth 1 clone operation only pulls down one branch. If the remote repository contains other branches, they won't be able to check them out locally without a pathspec error. After a git clone depth 1 operation, attempts to checkout an alternate branch will trigger a pathspec error.

Does git clone get all history?

Cloning an entire repo is standard operating procedure using Git. Each clone usually includes everything in a repository. That means when you clone, you get not only the files, but every revision of every file ever committed, plus the history of each commit.

How do I see my git repo history?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How do I pull changes from a cloned repository?

To pull down (i.e. copy) the changes merged into your fork, you can use the Terminal and the git pull command. To begin: On your local computer, navigate to your forked repo directory. Once you have changed directories to the forked repo directory, run the command git pull .


2 Answers

Use git pull --unshallow and it will download the entire commit history.

like image 161
Daniel Mann Avatar answered Sep 28 '22 21:09

Daniel Mann


Alternatively, you can also run git fetch --depth=1000000.

like image 21
Won Jun Bae Avatar answered Sep 28 '22 21:09

Won Jun Bae