- Starting in the same directory that you used for Connected Lab 5, make sure you don't have any outstanding or modified files (nothing to commit). You can do this by running the status command and verifying that it reports “working directory clean.”
$ git status
- If not already on the master branch, switch to it with git checkout master. Create a new one-line file.
$ echo "Initial content" > file5.c
- Stage and commit the file on the master branch.
$ git add .
$ git commit -m "adding new file on master"
- Start up gitk if it's not already running.
$ gitk &
- Create a new branch, but don't switch to it yet. (You can use whatever branch name you want.)
$ git branch newbranch
- Change the same line in the new file (still on the master branch).
$ echo "Update on master" > file5.c
- Stage and commit that change (still on the master branch).
$ git add .
$ git commit -m "update on master"
- Switch to your new branch.
$ git checkout newbranch
- On the new branch, make a change to the same line of the same file.
$ echo "Update on newbranch" > file5.c
- Stage and commit the file with the change on the new branch.
$ git commit -am "update on newbranch"
- Switch back to the master branch.
$ git checkout master
- Merge your new branch back into the master branch. (Git ...