diff --git a/02-branches.md b/02-branches.md index 6f0b3b9..fb3ec38 100644 --- a/02-branches.md +++ b/02-branches.md @@ -4,19 +4,19 @@ A branch is just a reference to a commit, it has a human-readable name and identifier. Instead of using the SHA-1 hash to reference a commit we can now use the name of a branch. -When creating a repository using `git init` a branch named 'master' is created +When creating a repository using `git init` a branch named 'main' is created for us, it is currently pointed at our latest commit. ![The current state of our repository](./img/basic-branch.png) -Let's designate 'master' as the branch for our main line of development, +Let's designate 'main' as the branch for our main line of development, anything on that branch should be stable. If we want to test out new features without breaking the main line then we can create new branches. ## Practical One We want to add a new file to our current project, but we don't want to mess up -'master'. +'main'. #### View the current branches @@ -24,10 +24,10 @@ We can see all of the branches in our repository. ```bash git branch -# stdout: master +# stdout: main ``` -#### Create a new branch from master +#### Create a new branch from main To add our new feature we want to add a new branch. Our new feature is adding information about our favourite animal so let's call the branch something @@ -36,7 +36,7 @@ descriptive like 'favourite-animal'. ```bash git branch favourite-animal # If we do a 'git branch' now we'll see our new branch is created, but we're -# still on master. Let's 'checkout' our new branch. +# still on main. Let's 'checkout' our new branch. git checkout favourite-animal ``` @@ -87,13 +87,13 @@ cat .git/HEAD ## Practical Two We have created a branch that has information about our favourite animal. Now -let's create another branch from master and add information about our favourite +let's create another branch from main and add information about our favourite TV show. We are currently on the branch 'favourite-animal'. We need to create -our new branch from master. +our new branch from main. ```bash -# Create a new branch named favourite-show from the branch master -git branch favourite-show master +# Create a new branch named favourite-show from the branch main +git branch favourite-show main git checkout favourite-show ``` diff --git a/03-merging.md b/03-merging.md index 144dad9..5b853bb 100644 --- a/03-merging.md +++ b/03-merging.md @@ -4,24 +4,24 @@ In the last section, we learned about creating new branches. Often branches are created temporarily to work on a specific piece of work. When that work is ready, then those changes are brought back into the main line again. -Remember the branches from the last section? Originally there was the master +Remember the branches from the last section? Originally there was the main branch, and then we created a branch called 'favourite-animal', where we made -changes. We can now merge those changes back into master branch, and delete the +changes. We can now merge those changes back into main branch, and delete the 'my-new-branch' since we won't need it anymore. ## Practical One - Fast-forward merging The simplest form of merging is *fast-forward* merging. Since branches are just -references to commits, and 'favourite-animal' is a direct descendant of master; -we can just update master to point to the same commit as 'favourite-animal'. +references to commits, and 'favourite-animal' is a direct descendant of main; +we can just update main to point to the same commit as 'favourite-animal'. This is the default way that git will merge when the target branch is an -ancestor of the source branch. First, `checkout` the target branch (master in +ancestor of the source branch. First, `checkout` the target branch (main in this case), and then use the `merge` subcommand to bring the changes from the source branch (favourite-animal) into this branch: ```bash -git checkout master +git checkout main git merge favourite-animal ``` @@ -42,7 +42,7 @@ message. ![Before creating a merge commit](./img/basic-merging-before.png) -While on the master branch, we can now merge the changes from the +While on the main branch, we can now merge the changes from the 'favourite-show' branch as follows: ``` bash diff --git a/04-conflicts.md b/04-conflicts.md index 73e5598..4899e5c 100644 --- a/04-conflicts.md +++ b/04-conflicts.md @@ -15,7 +15,7 @@ the action, and asks you to intervene. First, let's make a new branch and add a file: ``` bash -git checkout -b left master +git checkout -b left main echo "Left is the best" > conflict.txt @@ -27,7 +27,7 @@ Next, for the purposes of demonstration, let's create another branch, called `right`: ```bash -git checkout -b right master +git checkout -b right main echo "Right is the best" > conflict.txt git add conflict.txt diff --git a/07-rebasing.md b/07-rebasing.md index b085991..b41d645 100644 --- a/07-rebasing.md +++ b/07-rebasing.md @@ -14,7 +14,7 @@ Why rewrite history? Rebasing and Merging are two methods that achieve the same goal - the integration of changes from one branch into another branch -![rebase on master](img/01.gif) +![rebase on main](img/01.gif) ![rebase on feature](img/02.gif) ## Prerequisites @@ -34,8 +34,8 @@ git clone git@github.com:/git-tutorial.git git fetch git checkout rebase -# The rebase branch was branched from master a while ago -# It's out of date (master has moved on) +# The rebase branch was branched from main a while ago +# It's out of date (main has moved on) # And there's bad commits in our history that we're going to fixup git log --pretty=oneline @@ -45,11 +45,11 @@ git rebase -i HEAD~4 # Note the lack of a branch # Fix up the commits - think about re-ordering or (s)quashing # the version bumps and (r)eword the commit messages. # Also, delete commits that are of no value -git rebase origin/master +git rebase origin/main # Alternatively: # We can do both a history rewrite and a rebase via: -git rebase -i origin/master +git rebase -i origin/main ``` # Next Section diff --git a/08-stashing.md b/08-stashing.md index 6c96fac..ffaf368 100644 --- a/08-stashing.md +++ b/08-stashing.md @@ -25,18 +25,18 @@ git status # See what is stashed in this repository $ git stash list -stash@{0}: On master: experimental work with hello.txt +stash@{0}: On main: experimental work with hello.txt ``` Now make another change to _hello.txt_ before moving on to the next section ```bash # We want to stash your last change, check the status and our stash list $ git stash $ git status -On branch master +On branch main nothing to commit, working tree clean $ git stash list -stash@{0}: WIP on master: 21954be rerge branch 'favourite-show' -stash@{1}: On master: experimental work with hello.txt +stash@{0}: WIP on main: 21954be rerge branch 'favourite-show' +stash@{1}: On main: experimental work with hello.txt # Restore top/first stash (stash@{0}) & remove it from the list $ git stash pop # == apply && drop diff --git a/09-cherry-picking.md b/09-cherry-picking.md index b9bd8cc..7eccf31 100644 --- a/09-cherry-picking.md +++ b/09-cherry-picking.md @@ -2,7 +2,7 @@ Apply the changes introduced by some existing commits -Our main use-case for git-cherry-pick is for taking some bugfix commits from one branch, and applying them to another (e.g. a release branch and master) +Our main use-case for git-cherry-pick is for taking some bugfix commits from one branch, and applying them to another (e.g. a release branch and main) ## Prerequisite Ensure your current directory is that of the cloned repository in the previous practical. diff --git a/11-bisecting.md b/11-bisecting.md index 8bff715..7e0449c 100644 --- a/11-bisecting.md +++ b/11-bisecting.md @@ -11,7 +11,7 @@ In the `git-tutorial` repo: ```bash git checkout bisect -# Our bisect branch is a little ahead of of master (500 commits) +# Our bisect branch is a little ahead of of main (500 commits) # At some point, a commit slipped in that means our app doesn't start # and our tests fail. # Lets use git bisect to find the broken commit diff --git a/12-config.md b/12-config.md index f68902a..0613dc1 100644 --- a/12-config.md +++ b/12-config.md @@ -67,7 +67,7 @@ Aliases are really useful Lots of other useful aliases and config customization examples here: -https://github.com/matthewmccullough/dotfiles/blob/master/gitconfig +https://github.com/matthewmccullough/dotfiles/blob/main/gitconfig diff --git a/14-under-the-covers.md b/14-under-the-covers.md index c4bbe45..8ab6ca6 100644 --- a/14-under-the-covers.md +++ b/14-under-the-covers.md @@ -28,9 +28,9 @@ $ tree -L 1 ./.git `COMMIT_EDITMSG` can be useful with the hub command to create a pull-request on github with a single command ```bash -# Create a PR against master branch of the repo in the feedhenry org +# Create a PR against main branch of the repo in the feedhenry org # with the contents of the most recent commit message as the description -git pull-request -b feedhenry:master -F ./.git/COMMIT_EDITMSG +git pull-request -b feedhenry:main -F ./.git/COMMIT_EDITMSG ``` ## Git objects - what are they? @@ -70,8 +70,8 @@ Porcelain provides a more user-friendly interface to the plumbing https://git.io/v1Bt5 ```bash -# Create a new branch from master & checkout -git co -b ungit master +# Create a new branch from main & checkout +git co -b ungit main # Make a new blob object blob_sha1=$(echo "Let's ungit" | git hash-object -w --stdin) @@ -103,10 +103,10 @@ c838b24 HEAD@{1}: merge c838b2447de706f53eaabed16c371abbb6d82b03: Fast-forward e29b7ee HEAD@{2}: checkout: moving from cp-conflict-example to ungit bf196ea HEAD@{3}: commit (cherry-pick): Bumping version to 2.0.8 e29b7ee HEAD@{4}: checkout: moving from cp-example to cp-conflict-example -b2d9004 HEAD@{5}: checkout: moving from master to cp-example -e29b7ee HEAD@{6}: checkout: moving from cp-example to master +b2d9004 HEAD@{5}: checkout: moving from main to cp-example +e29b7ee HEAD@{6}: checkout: moving from cp-example to main b2d9004 HEAD@{7}: cherry-pick: name change -e29b7ee HEAD@{8}: checkout: moving from master to cp-example +e29b7ee HEAD@{8}: checkout: moving from main to cp-example e29b7ee HEAD@{9}: clone: from git@github.com:fheng/git-tutorial.git # Checkout a previous state