Skip to content

Instantly share code, notes, and snippets.

@docPhil99
Last active March 2, 2020 16:27
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 docPhil99/9e4e09c120ab18bd572ff25cb5030769 to your computer and use it in GitHub Desktop.
Save docPhil99/9e4e09c120ab18bd572ff25cb5030769 to your computer and use it in GitHub Desktop.
Some useful notes on git

Split directory into a new repo

  • clone the repo into a new directory
  • cd into it
  • git filter-branch --prune-empty --subdirectory-filter FOLDER-NAME BRANCH-NAME
    • where:
    • FOLDER-NAME: The folder within your project that you'd like to create a separate repository from.
    • BRANCH-NAME: The default branch for your current project, for example, master.
  • Update the remote git remote set-url origin https://github.com/USERNAME/NEW-REPOSITORY-NAME.git
  • Verify git remote -v
  • Push the changes git push -u origin BRANCH-NAME

Branch

  • Delete a branch 'git branch -d NAME'

Submodule

  • adding git submodule add REPO
  • to pull new code: git pull --recurse-submodules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment