Git -For beignner (Tutorial) -- Part2
Git- Branching:
What is branching?
Branching is the
way to work on different versions of a repository at one time.
By default your repository has one branch named master which
is considered to be the definitive branch. We use branches to experiment and
make edits before committing them to master.
To create a new
branch
1.
Go to your new repository hello-world.
2. [rprasad@vm
git-repos]$
cd hello-world/
3.
2.
Do the checkout
3. [rprasad@vm
hello-world]$
git checkout -b test
4. Switched to a new branch
'test'
5.
3.
Run git status,
to check where you are:
4. [rprasad@vm
hello-world]$
git status
5. # On branch test
6. nothing to commit, working
directory clean
7.
4.
Check the branch details
5. [rprasad@vm
hello-world]$
git branch
6. master
7. * test
8.
5.
Try, editing README,
6. [rprasad@vm
hello-world]$
vi README.md
7. [rprasad@vm
hello-world]$
cat README.md
8. # hello-world
9. Testing
#Branch testing
verifying
changes
6.
Verify, with git status
[rprasad@vm
hello-world]$
git status
#
On branch test
#
Changes not staged for commit:
# (use "git add <file>..." to
update what will be committed)
# (use "git checkout --
<file>..." to discard changes in working directory)
#
# modified: README.md
#
#
Untracked files:
# (use "git add <file>..." to
include in what will be committed)
#
# .README.md.swp
no changes added
to commit (use "git add" and/or "git commit -a")
Comments
Post a Comment