![git create branch and commit git create branch and commit](https://images.ctfassets.net/vtn4rfaw6n2j/5Zf5kRJrm1xvKzPbmpy3f0/64bcbca6ccdb00ae49446f216eed9bc3/image2.png)
We can do -set-upstream or we can do -u, and then origin jsChanges. We have to push while setting the upstream to the origin jsChanges, just like this is origin master. When we do, we get a fatal error, because if we do git branch -vv, we don't have jsChanges linked to any remote branch. If we do a git log oneline, then we have "Adds Hello World" on the jsChanges branch, which has diverged from the master branch. We'll commit that and we'll say, "Adds Hello World." ProTip: GitKraken will automatically checkout the branch for you immediately after the branch has been created, so you can get straight to work on the right file. Note: The flag 'b' here tells Git to create a new branch with the branch name succeeding in the flag. To create a new Git branch in GitKraken, you will simply right-click on any branch or commit and select Create branch here.
Execute this command and check the output: git checkout -bThen, let's save that and do a git status. Since it is a frequent requirement that we create a branch and switch to it at the same time, this command helps a lot to achieve the same. After staging changes to many files, you can alter the order the changes are recorded in, by giving pathnames to git commit. We'll make a function called helloWorld again, and we can say alert i. The command git commit -a first looks at your working tree, notices that you have modified hello.c and removed goodbye.c, and performs necessary git add and git rm for you. Master is linked to a remote, but jsChanges is just a local branch for now. If we do git branch -vv, for verbose mode, then we can see the current commit that we're on for each branch, and we can see the remote that we're on for each branch.
![git create branch and commit git create branch and commit](https://i.stack.imgur.com/6qEWk.jpg)
Or, in one command: git checkout -b newBranch As mentioned in the git. We can also do git branch to see all of our branches. If you hadnt made any commit yet, only (1: branch) and (3: checkout) would be enough. If we do a git status, we can see that we're on the branch jsChanges.
![git create branch and commit git create branch and commit](https://git-scm.com/book/en/v2/images/commits-and-parents.png)
That's what we'll do to make a new branch. We can do git branch and then our branch name like jsChanges or we can do git checkout -b jsChanges. Instructor: We can create a new branch in two different ways.