EJERCICIO_PRÁCTICO
Working with Branches
Working with Branches
1. View branches
bashgit 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.
bashgit switch main git merge new-feature
Practical Exercise
- Create and switch to
feature-header:git switch -c feature-header - Create
header.htmland commit it. - Switch back to main:
git switch main. - Notice that
header.htmldisappears! (It's safe in the other branch). - Merge the feature into main:
git merge feature-header. The file reappears.
