Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
linuxcommandline
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Giriram Kumar Mohana Sundara Shanmugam
linuxcommandline
Commits
d8902b7f
Commit
d8902b7f
authored
9 years ago
by
Holger Dinkel
Browse files
Options
Downloads
Patches
Plain Diff
add branching
parent
7af07819
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
git_beginner/introduction.rst
+38
-0
38 additions, 0 deletions
git_beginner/introduction.rst
with
38 additions
and
0 deletions
git_beginner/introduction.rst
+
38
−
0
View file @
d8902b7f
...
...
@@ -435,6 +435,44 @@ specify the hash or name of the revision::
Branching
=========
Branches are deliberately lightweight in git, meaning you can very easily create (and delete) branches.
So it's generally a good idea to use different branches...
To list all existing branches, you type:::
git branch -a
To create a new branch you can type either:::
git branch NewBranch
git checkout NewBranch
or, simpler:::
git checkout -b NewBranch
.. note:: Remember you need to switch to new branches, by using ``git checkout branchname``!
Any new commit will now go into this branch, not affecting any other branch.
In order to take your changes from one branch into another, you need to merge the branches:::
git merge master
You always merge **into** the currently checked out branch. In this example we merge the branch `master` into `NewBranch`.
This will update `NewBranch` with all changes that have been committed to `master`.
Since `NewBranch` is now up to date, we can also merge back it's changes into `master`:::
git checkout master
git merge NewBranch
Finally, we can delete this branch:::
git branch -d NewBranch
.. Using centralized workflow
.. ==========================
..
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment