I have a dataset from 2014 that includes bug reports and the corresponding fix commit. The commit SHA is seven digits long, and I guess, in 2014, it was sufficient to identify a commit uniquely. However, in 2022 7 digit SHAs can not identify all commits uniquely anymore.
Therefore, I wonder whether I can clone the repository with commits only on or before 2014 so that seven-digit SHA is sufficient to identify all commits uniquely.
CodePudding user response:
If you only want to clone everything before a certain date and from one branch, create a new branch at the last commit to be included either on the server or by pushing a local branch.
After this, clone the repository using the --branch your_created_branch
option to checkout the branch that you created and the --single-branch
option to clone only the history leading up to the branch that you specified.
Be aware that if you attempt to fetch or pull at any point in the future, you may end up pulling other more recent commits and branches into the local repo.
See documentation for git clone here.
CodePudding user response:
Repository clone will give you whole commit history of that repository. So its not a good idea.
- You can type command
git log
which will show details about all the previous commits - Than you can change state to a specific/desired commit by typing
git checkout commit-hash
. Commit hash will be unique id of that commit you want to move. - To narrow down list of commit you can also try this command
git log --since=2014-05-05 --until=2014-05-06
. This will retrieve result between dates