I have a private repository on GitHub that I want to make public. However, some of the initial commits contain information that I don't want to publicize (hard-coded credentials, etc).
What is the easiest route to make the latest commit public (I don't really need or want the previous commits in the public repository) without including some or all of the commit history?
i.e. if you just want the latest commit use git clone --depth 1. branch is the name of the remote branch that you want to clone from. i.e. if you want the last 3 commits from master branch use git clone --depth 3 -b master. repo_url is the url of your repository.
Yes you can, but there's no need to copy the full working tree. You can copy just the . git folder without the working tree (i.e. as a "bare" repo) and then checkout the latest working tree on the other machine.
Go into the repo you want to copy first. Then assuming you have a new repo already set up, use the clone link and that's it. It will copy over all history over to your new repo.
You can limit the depth of the history while cloning:
--depth <depth> Create a shallow clone with a history truncated to the specified number of revisions.
Use this if you want limited history, but still some.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With