If you’re using the terminal, you will use the git branch command followed by your desired branch name to create a Git branch in your repository.
It should look something like this:
git branch feature-A
This will create a Git branch on your currently checked-out reference.
Before you perform actions on your branches in your Git repository, it’s important to know which branch you’re targeting. If you aren’t using a Git GUI, like GitKraken, to visualize your work, it’s likely you won’t be able to remember the names of each local branch, especially in a large Git repository.
To view a list of your local Git branches, you can run
at any point during your workflow.
Merging branches in Git is useful for combining changes from one branch into another, and for preserving history.
Let’s say you have a master branch with changes. You then branch off into a feature branch and make additional changes.
To merge the feature branch, you will want to first checkout your master branch with
git checkout master
Then use the command
git merge feature
You will then merge changes from the feature branch over to master, adding all changes from the feature branch to master. …
If you have a remote branch, you likely have a local branch with the same name. A typical workflow is to first make commits locally and then push those changes to the remote branch.
However, sometimes you need to push to a different remote branch. To set the upstream branch in Git, use the following command:
$ git push --set-upstream <remote> <branch>
This will push your local branch to the new remote branch.
Originally published at https://gitkraken.com.
Before you get into deleting remote branches in Git, we recommend you familiarize yourself with how to delete local branches.
Deleting a remote branch works a bit differently than deleting a branch locally in Git.
If you run the git branch -d command associated with a remote branch, Git will tell you the branch is not found.
At its core, the branching model offered by Git is intended to help you avoid merging unstable code into the main codebase. Working with branches in Git is a breeze, especially if you’re working with the GitKraken Git client to visualize your repository.
Let’s start by going over how to delete a Git branch locally using the command line.
To delete a local branch in Git using the terminal, you’re going to run the git branch command and pass in the -d flag. Next, you will pass in the name of the branch you wish to delete.
What does ‘diff’ mean in Git? In this beginner Git tutorial, we will walk you through the concept of a diff and the benefits of using a robust diff tool, like that offered in the GitKraken Git GUI.
A diff takes two data sets and shows you what has changed between them. Data sets can be files, commits, branches, etc.
Let’s look at an example using two commits; let’s say we want to see what has changed between Commit 1 and Commit 3.
The diff will compare the differences between the two commits, showing what files were added, deleted…
What is interactive rebase in Git? And how does one rebase interactively? 🤔In this advanced Git tutorial, we will go over everything you need to understand what interactive rebase is, how to confidently utilize the feature in GitKraken, and an example of how interactive rebase works in Git.
Before we get into interactive rebase, let’s do a quick refresher on rebasing in Git. As you may recall, rebasing takes the commits from one branch and places them onto a different branch.
Learn about the differences between merging and rebasing in this intermediate Git tutorial video.
Typically, this process happens in…
If you want to find out what tools these developers are using, that’s where our survey comes in. For the fourth year in a row, Axosoft asked our global community of software developers to tweet their top 5 #MustHaveDevTools. We received 700 responses this year and ranked the tools in order of most votes.
Let’s dive into the…
The various methodologies that have popped up in the last decade related to software project management are overwhelming. How many roadmaps do we need to encourage successful software development, innovation, and faster deployment?
Widespread project management styles include Waterfall, Agile (scrum, kanban, hybrids), Rapid Application Development (RAD), Six Sigma, and many, many more. A more recent methodology that’s trending across the dev world is DevOps, the integration between development and IT operations.
In GitLab’s 2018 Global Developer Report, the authors draw a harsh distinction between teams using an Agile vs DevOps infrastructure.
“Organizations that have adopted DevOps are more likely…