$ mkdir whatever # Create a working directory
$ cd whatever # Get inside if it
$ brew install lorem # Install this lorem thing
$ lorem -n 800 | split -b 2000 - file_ # Create three files of lorem ipsum
$ git init . # Create a new Git repo right here
$ git add * # Add all the files you just created
$ git commit --message "First Commit" # Commit!
-
Make a branch with
git branch new_branch_name
-
Checkout (switch) to that branch
git checkout new_branch_name
Note: Alternatively, use
git checkout -b new_branch_name
to do both in one command! -
Edit a file and make commit on that branch. Create a new file if you'd like!
Note: If you made a new file notice how you cannot use
git commit --all --message ""
to add and commit this new file in one step. You'll first have to usegit add new_file_name
. -
Check the logs to see your commit with
git log
orgit show
to only show the last commit!
-
Switch back to the master branch with
git checkout master
Protip:
git checkout @{-1}
! -
Use
git log
orgit show
again to see that your commit isn't on master. -
Merge your "other" branch into master with
git merge new_branch_name
-
Read that whole log output. Use
git log
again and observe how your commit is now in master!