A Guide to Git & GitHub

In this course we will be learning about version control especially Git and GitHub which provides hosting for Git version control.

Git branches

Please check below example of branching in the real world.

1. Start implementation on a User management feature.
2. Create a branch for example feat/ECS-12-user-management.
3. Commit your work in feat/ECS-12-user-management branch.

At this point, you identify one bug in production

1. Switch to master branch.
2. Create a branch hotfix/user-profile-not-working.
3. After code review, merge hotfix/user-profile-not-working branch into master and push.
4. Switch to feat/ECS-12-user-management branch and continue your work.

List all local branches in repository

$ git branch

a * will appear next to the currently active branch. With -a: show all branches (with remote).

$ git branch [-a]

Creating a New Branch

$ git branch <branch-name>

Switch working directory to the specified branch. With -b.
Git will create the specified branch if it does not exist.

$ git checkout [-b] <branch-name>

Switch branch
switch to another branch and check it out into your working directory

$ git checkout <branch-name>

Deleting a remote branch
Sometimes branches need to be cleaned up for book keeping or organisational purposes. The fully delete a branch, it must be deleted locally and also remotely.

$ git branch -D <branch-name>
$ git push <remote> <branch-name>


Previous Next

Unlock Your Potential with Engineeous

Get Started