Friday, October 23, 2015

Git Tips & Tricks: Make the current commit the only (initial) commit

Here is the brute-force approach, which also removes the configuration of the repository.

Brute-force approach

  1. Remove local repository with all history (same as physically delete .git):

     rm -rf .git
    
  2. Recreate the Git repo with only the current content.

     git init
     git add .
     git commit -m "Initial commit"
    
  3. Add origin and force push to GitHub.

     git remote add origin <github-uri>
     git push -u --force origin master
    

Interactive rebase

Follow Attlasian rewriting the history


see Also


No comments:

Post a Comment