This write-up will explain the process of copying a Git repository without history.
How to Clone Particular Git Repository History?
To copy a Git local repository without log history, follow the below-listed steps:
- Navigate to the local directory.
- Choose a particular GitHub Repo and copy its HTTP URL.
- Clone Git Repo without history using the “git clone –depth 1 <remote-URL>” command.
- View commit history.
Step 1: Switch to Particular Local Repository
First, type out the “cd” command along with the desired path and redirect to it:
Step 2: Copy Remote URL
Then, open GitHub, navigate to the required remote repository that you want to clone, and copy its “HTTP URL” to the clipboard:
Step 3: Clone Remote Repository
Now, use the “git clone” command along with the desired depth and HTTP URL of the remote repository to copy that particular repository:
Here, the “–depth” option is used to get the desired amount of commits. The “depth 1” will include the latest commit only:
Step 4: Navigate to Remote Repository
Next, redirect to the cloned Git repository using the “cd” command:
Step 5: Check Reflog
Lastly, view the commit history by checking the reference log:
The below-screenshot displays the latest commit only, which means the Git repository has been copied successfully without history:
We have demonstrated the easiest method of copying a Git repository to a local repository without history.
Conclusion
In order to copy the Git repository without history, first, switch to the local repository. Then, open GitHub, go to a particular GitHub remote repository, and copy its URL. After that, copy the remote repository to the local repository by executing the “git clone –depth 1 <remote-URL>” command. Lastly, view the Git repository reference log to verify the changes. This write-up explained the process of copying a Git repository without history.