I have git repo with two unrelated branches, master and configs.
I’ve created configs, purged all the files and then placed in configuration files only.
Now I want to push this on remote repo, but as it were new, empty branch (without logs of all my changes and old revisions of original branch).
How can I purge all the history and push it?
Purging all the files doesn’t get rid of the history. You need to create a branch that has no history first, and the add your config files. These days
git checkouthas a--orphanoption that makes a branch with no history. Here’s the information on the--orphanoption:Here’s a link to the documentation for checkout. You can also run
git help checkoutas well.Once you’ve created your branch without history, then when you push it to the server, it won’t have that history either. FWIW, it helps me to think of
git pushas "make the remote branch look the same as my local one". So if you have history, and push, it will have history. If you don’t, then the pushed branch won’t.