Logo hdtoledo
hdtoledo.dev
Módulos_del_Sistema
EJERCICIO_PRÁCTICO

Working with Branches

Working with Branches

1. View branches

bash
git branch

2. Create and switch branches

bash
# Create and switch in one command git switch -c new-feature

(Note: Older tutorials use git checkout -b, which does the exact same thing).

3. Merging

When finished, you merge the branch back into main. Crucial: You must always be on the RECEIVING branch (main) before merging.

bash
git switch main git merge new-feature

Practical Exercise

  1. Create and switch to feature-header: git switch -c feature-header
  2. Create header.html and commit it.
  3. Switch back to main: git switch main.
  4. Notice that header.html disappears! (It's safe in the other branch).
  5. Merge the feature into main: git merge feature-header. The file reappears.