Source control

How to keep up to date

This document contains git commands that need to be used in order to synchronize branches of the main repository.

To keep up to date with the latest changes in the repository (Git Hub) we need to do a few things on our pc, otherwise, CONFLICTS WILL HAPPEN!!!


Ensuring 'nette' has the latest changes from 'stu':

IMPORTANT! We need to make sure that everything is up to date with github BEFORE we start to make changes to ANY file in VS Code.

Open Nutty's Kitchen in VS Code (the code editor)

open Nutty's Kitchen in vs code
vs code nuttys kitchen

# Open a terminal window: Press CTRL and hold while you press ' (it's on the same key as the @ symbol)

open a terminal window: press CTRL + '
terminal window

# Open a Git Bash Terminal: Press the down arrow (next to the '+' symbol) on top right hand side of the terminal window.

Select 'Git Bash' from the pop up menu.

open a Git Bash terminal:
open git bash
the Git Bash terminal:
git bash terminal

# Now we can run the following commands to ensure that your branch (nette) is up to date with my branch (stu):

Copy & paste the commands (shown as: git some-command-to-run) into the Git Bash terminal and press ENTER to run the command.

  1. Fetch the latest changes from the remote repository with the following command:
    • git fetch origin
  2. Check if the `stu` branch exists locally. It should be shown in the terminal:
    • git branch --list stu
  3. If the `stu` branch exists locally, check it out ('checkout' means 'switch to'):
    • git checkout stu
  4. If the `stu` branch does not exist locally, create a local copy of the remote `stu` branch:
    • git checkout -b stu origin/stu

Otherwise skip to step 5.

# Now we are sure the 'stu' branch exists on your pc we can proceed:

  1. Pull the latest changes into the local `stu` branch with the following command:
    • git pull origin stu
  2. Check out (switch to) the `nette` branch with the following command:
    • git checkout nette
  3. Merge the `stu` branch into the `nette` branch with the following command:
    • git merge stu
  4. Resolve any merge conflicts if they arise.
    • # STOP IF THERE ARE CONFLICTS!!! and go no further. Otherwise proceed:
  5. Push the updated `nette` branch to the remote repository with the following command:
    • git push origin nette

### This is a shorter version of the above!!!!!

# Copy and paste these into a Git bash terminal and press 'ENTER':

git fetch origin
git branch --list stu

# If the `stu` branch exists locally it will be shown in the termiminal.

# If the `stu` branch does not exist locally copy & paste the following into the 'Git Bash' terminal & press 'Enter':

git checkout -b stu origin/stu

# Now we know the 'stu' branch definately exist on your pc, copy & paste the following into the 'Git Bash' terminal & press 'Enter':

git checkout stu
git pull origin stu
git checkout nette
git merge stu

WARNING: If there are conflicts STOP!!! Do no more, these have to be fixed!!!

# If there are no conflicts, proceed to `push` the updated local `nette` branch to the remote branch (on Git Hub)

git push origin nette

Just take note of any spurious messages in the terminal and then close each terminal with the following command:

exit

All should be good now.

Happy Coding!