Hands-on Git Tasks - Part #5 of 5 | Merging
This post is part of a 5-post series on using Git.
Hands-on Git Tasks - Part #1 of 5 | First Git Commit
Hands-on Git Taks - Part #2 of 5 | Checking Git Objects
Hands-on Git Tasks - Part #3 of 5 | Navigating Project Branches
Hands-on Git Tasks - Part #4 of 5 | Using Remote Repository
Hands-On Git Tasks - Part #5 of 5 | Merging
Follow these steps for an example of how to merge code from a 'feature' branch into the 'main' branch. Did glance over branching in an earlier tutorial, but did not cover the merging of branches.
01. Go to the local-repo folder
02. check branches: git branch
03. create a new branch: git branch feature
04. check branches again: git branch
05. checkout the feature branch
06. create, add and commit a new file in 'switching' branch: switching.txt
ls
echo "circuit, packet, message" > switching.txt
git add switching.txt
git commit -m "Added switching feature"
ls
07. get-back to the 'main' branch: git checkout main
08. create, add, and commit a new file in the 'main' branch: routing.txt
ls
echo "static, default, dynamic" > routing.txt
git add routing.txt
git commit -m "Added routing to main"
ls
09. merge 'feature' into 'main' branch.
ls
git merge feature
ls
git log
10. delete 'feature' branch
git branch
git branch -d feature
git branch
11. Validate that you have all the files you want in main.
If you want to find me, you can catch me, Lewis Lampkin, III at LinkedIn: https://www.linkedin.com/in/lewislampkin
If you want to read my blog: https://www.lewislampkin.com
Comments
Post a Comment