Star

Created With

linkCreating Branches with Git

Branch Diag

What are git branches? Essentially like a tree branch!

But this is a special tree. This tree not only branches, but later on down the track is capable of merging (or rebasing!) those branches back to its main trunk

Okay, maybe an arborist can chime in here.. but afaik tree branches don't usually merge back together 😆

linkWhy might we want to create a branch?

Writing code directly to your main repository can be dangerous. Especially when you are working in a large team, where many sub-teams work on many different features!

The brilliant part of branches is that you can check out a branch to work on for example a new feature. You can let your users test that branch.

Once all is well and the new feature works as expected you can then merge it. Simple!

linkHow to create a new branch from your git repository

Using the git branch command

linkList the current branches on your local repo

1link$git branch --list OR just git branch

linkList current branches in the remote repo

1link$git branch -a

linkCreate a new branch

1link$git branch <branchname>

linkDelete a branch (safely)

1link$git branch -d <branchname>

linkForce delete a branch, ignoring un-merged changes (unsafe)

1link$git branch -D <branchname>

linkWith GitHub, you can do a whole bunch of cool things interactively with your branches

For example, easily rename your master branch to main!

Screen-Shot-2021-03-13-at-10-53-46-am.png

Creating Branches with GitWhy might we want to create a branch?How to create a new branch from your git repositoryList the current branches on your local repoList current branches in the remote repoCreate a new branchDelete a branch (safely)Force delete a branch, ignoring un-merged changes (unsafe)With GitHub, you can do a whole bunch of cool things interactively with your branches
Content

Home Backstory Why Git? Setting Up GitHub GitHub CLI Your GitHub Profile GitHub Pages Creating A New Repo Cloning A Repository Your First Commit Ignoring Files In Git Stashing Your Changes Branching With Git Merging Git Branches Rebasing Vs Merging Git Workflows Fork And Pull Flow Your First Pull Request Automated Security Alerts Seeing The Differences Removing/Deleting Files Reverting Your Commits Configuring your Git Commit Templates Creating Shortcuts Dotfile Management Sponsoring Open Source Handy Commands Thank You



Developer Student Clubs

logo2.png