Skip to content

Instantly share code, notes, and snippets.

@jfsiii
Created June 26, 2018 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jfsiii/5a2ca6f9734a1a04ce9a87bd5f917803 to your computer and use it in GitHub Desktop.
Save jfsiii/5a2ca6f9734a1a04ce9a87bd5f917803 to your computer and use it in GitHub Desktop.
Creating a new git repo & branches
~ ‣ mkdir -p foo
~ ‣ cd foo
~/foo ‣ git init
Initialized empty Git repository in /Users/jfsiii/foo/.git/
~/foo [master @ HEAD] ✓ ‣ git branch new-branch
fatal: Not a valid object name: 'master'.
~/foo [master @ HEAD] ✓ ‣ echo 'first' > test.txt
~/foo [master @ HEAD] ✗ ‣ git add test.txt
~/foo [master @ HEAD] ✓ ‣ git commit -am 'master branch created on first commit'
[master (root-commit) ff11ac5] master branch created on first commit
1 file changed, 1 insertion(+)
create mode 100644 test.txt
~/foo [master @ ff11ac5] ✓ ‣ git branch new-branch
~/foo [master @ ff11ac5] ✓ ‣ git checkout new-branch
Switched to branch 'new-branch'
~/foo [new-branch @ ff11ac5] ✓ ‣ git checkout -b branch-off-new-branch
Switched to a new branch 'branch-off-new-branch'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment