TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Git

Create a Git Branch

Git Tutorials

Overview

In this tutorial, let’s learn how to create a branch using GitHub and Git client. Branching allows us to work on different versions of the same repository. Using branches we can work on new features without making changes to the original master branch.

 

Git Branching

 

Create a branch on GitHub

Log in to GitHub.

Navigate to the project repository.

Click on the master branch.

Enter the new branch name.

Click on the Create branch link.

 

Create branch Github

 

Create a Git branch

We can use the git branch command to create, list branches on the command line.

$ git branch <branchname>

To create a new branch using the Git command line and to switch to the newly created branch, issue the command:

$ git checkout -b git-branch-demo

 

git branch demo commit

 

$ git checkout -b git-branch-demo
Switched to a new branch 'git-branch-demo'

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git status
On branch git-branch-demo
Untracked files:
 (use "git add <file>..." to include in what will be committed)
 src/GitBranchFeatureDemo.java

nothing added to commit but untracked files present (use "git add" to track)

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git add .

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git commit -m "Git-demo-branch Commit"
[git-branch-demo 33d4a37] Git-demo-branch Commit
 1 file changed, 9 insertions(+)
 create mode 100644 src/GitBranchFeatureDemo.java

hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git push
fatal: The current branch git-branch-demo has no upstream branch.
To push the current branch and set the remote as upstream, use

 git push --set-upstream origin git-branch-demo


hp@LAPTOP-3NKORD70 MINGW64 ~/SampleProject (git-branch-demo)
$ git push --set-upstream origin git-branch-demo
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 4 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 509 bytes | 101.00 KiB/s, done.
Total 4 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
remote:
remote: Create a pull request for 'git-branch-demo' on GitHub by visiting:
remote: https://github.com/yskumar007/SampleProject/pull/new/git-branch-demo
remote:
To https://github.com/yskumar007/SampleProject.git
 * [new branch] git-branch-demo -> git-branch-demo
Branch 'git-branch-demo' set up to track remote branch 'git-branch-demo' 
from 'origin'.

Create branch using Git GUI

We can also create a branch using Git GUI.

$ git-gui

From the Git GUI menu options choose Branch >> Create…

Enter branch name and click on the Create button.

 

Git Gui New Branch

 

Pull request

https://www.testingdocs.com/create-a-pull-request/

 

Git Tutorials on this website:

https://www.testingdocs.com/git-tutorials/

More information on Git, official website:

https://git-scm.com/

Related Posts

branching

Git /

What is Branching?

Git Install on Linux

Git /

Install Git on Ubuntu Linux

Version_Control_Centralized

Git /

Overview of Version Control Systems

Git Website

Git /

Getting Started with Git Version Control

Install Git on Windows 10

Git /

Install Git on Windows 10

‹ Create a pull request› Push changes to git remote repository

Recent Posts

  • Scaler Academy – An Online Learning Platform
  • Difference between PHP and JavaScript?
  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com