Skip to content

Instantly share code, notes, and snippets.

@warengonzaga
Last active March 15, 2022 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warengonzaga/67dc236ee5d6249725cd0ec7451c407a to your computer and use it in GitHub Desktop.
Save warengonzaga/67dc236ee5d6249725cd0ec7451c407a to your computer and use it in GitHub Desktop.
Git - New Empty Branch

New Empty Branch - Git Commands

  1. Switch to a new empty branch.
git switch --orphan <branch-name>
  1. Remove all the files, mostly all in the .gitignore file will start to show here.
rm -rf *

💡 The rm -rf * command will delete all the files in your current working directory. If unsure, delete the files manually.

  1. Add your changes to your new empty branch.
  2. Lastly, push your changes
git push -u origin <branch-name>

Reference: https://stackoverflow.com/a/34100189/17252778

@DJZK
Copy link

DJZK commented Mar 15, 2022

Add better context. rm -rf * is a dangerous command, atleast add disclosures and warnings.

@warengonzaga
Copy link
Author

Add better context. rm -rf * is a dangerous command, atleast add disclosures and warnings.

You're right, let me update it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment