Testing Git Branches and Merging back the Changes

Testing Git Branches and Merging back the Changes


This content is open source. Help improve it.

I made a test branch for the swapping jekyll for hugo article, and then merged the changes back to master, once I had it running.

Checkout test branch

Use the command git checkout -b will allow you to create a local branch for testing.

I will call my new branch test-hugo so the command will be like so:

git checkout -b test-hugo

Some git basics for newbs like me

Git keeps track of all your files, but not just the files, but everything in the repository.

Every commit, git remembers.

“yes yes I know”

However, it really boggled my mind the first time I tried it locally.

I can change to a branch or another point in the history of this repository, and git tucks away the one I’m working on… and the whole directory changes and like wait…

where did all my files just go?

When you push a repository to GitHub they keep a copy too.. but git is really awesome beyond github. If it was invented today they would call it a blockchain :rofl:

Git is Magic!

it sure feels that way, especially the first time I realized what it was doing. I still have a sense of wonder and mystery around Git.

You probably knowbut you don’t need github at all, and I’m learning that a significant portion, of git repositories are never exposed to the public.

Outside of GitHub and its imitators, most contributors to a project don’t have a published version of their repository online at all, skipping that step and saving some time. - What is a Fork?

git checkout -b is just the same as creating a new directory, copy pasting the repo files there to test, and testing it out there. Except git makes it look like magic, and keeps track of your progress!

Merging changes back to the master branch

git checkout master
git pull origin master
git merge test
git push origin master