Changing Branches

Changing Branches

Now that you have a new branch to work with you can switch or checkout the branch by using the git checkout command.

git-checkout

Run the command git checkout bug-fix.

Once more check your current branch status with the git branch command.

Running the Python Program

Run the main.py program within py-demo-web-logs to view the output:

big-fix

You will notice that the current output has the following issues:

  • ip: /home/student
  • home-dir: 127.0.1.1

These two values should be swapped.

Fix the Bug

Open up the main.py file with nano or vim and change the print statement to look like the following:

print("{}: {}@{} ip: {} home-dir: {}".format(ts, user, hostname, local_ip, home_dir))

big-fixed

Write the changes and exit back to the terminal.

Warning

Make sure to write/save your changes before exiting!

Now if you run the main.py program again you should see that the error has been fixed!

python3-main

Bonus

If you would like to check that the changes you made are correct you can run the command git checkout master and then run the command git checkout bug-fix-solution to view the file it contains and compare it to the change you made on the bug-fix branch.

Recap:

  • Changing branches with the git checkout command
    • Making minor changes to existing files