Showing posts with label Git Branch. Show all posts
Showing posts with label Git Branch. Show all posts
Friday, January 2, 2015
Tuesday, December 16, 2014
Checkout in SourceTree (switch branches)
In
the previous post Creating a new Branch in SourceTree we created a new branch “GitCommands”, we now have 2 branches
“master” and “GitCommands” and the [Head] is pointing to the “GitCommands”
branch, we will switch from this branch to the “master” branch.
1.
Open source Tree.
2.
Before switching the branch, check the
branch to with the [head] is pointing, now we are in the GitCommands branch.
3.
Click on the Checkout option from the Toolbar.
4.
In the pop-up, select the master branch and
click OK.
5.
The [head] now points to the [master]
branch, the files in the local working folder are updated to reflect the files
in the [master] branch.
Notice
that the file “Git Commands.docs” added to the “Git Commands” is not available
in the local Working Folder, this is because when you switch to a different
branch, the local working folder is refreshed with the files in that branch.
6.
Only one copy of the working folder is
maintained, and the files in the working folder reflects the files in the
branch to which the head is pointing, hence before switching from one branch to
another make sure that the changes are properly committed.
7. You can also Checkout to an
existing branch by right clicking on the branch and selecting the “checkout”
option.
Creating a new Branch in SourceTree
Branching
is an important feature of any version control system. Branching concept in Git
is quite different from the conventional version control systems. In
conventional version control systems’ branching involves creating a physical
set of files/documents and storing them as a separate copy for that branch.
In Git branching is done in a different logic, Git basically stores all the changes to the repository in the form of commits, and branching is done just by switching the [head] pointer between the commits.
In Git branching is done in a different logic, Git basically stores all the changes to the repository in the form of commits, and branching is done just by switching the [head] pointer between the commits.
Let us now create a new
branch called GitCommands and add a new file Git Commands.docx to the new branch.
Branch Vs Checkout in Git
Branch
and Checkout do the same thing but there is a small difference between the two.
This post explains the difference between the operation of the branch and checkout commands in Git.
Sunday, December 7, 2014
List out all the branches in the current repository
In the previous post we saw on how to switch to a
specific branch using the checkout
command, at times we might have more branches in a repository which we cannot
remember always, the $git branch
command is used to list out all the branches in the current repository.
The following command lists all the branches in the
repository.
Checkout a branch using Git Bash
The checkout command is used to switch to a specific branch, also the checkout command gets the latest
changes from the specified branch and updates them to the local working folder.
Before using the checkout command to switch to a branch, the specific branch should
be created using the git branch
command.
The checkout command can be used with
the –b switch to create a new branch and switch to that branch in a single
command.
Subscribe to:
Posts (Atom)