Git contd
Branches in Git
- Branches allow parallel development. we might need paralled development for
- multiple customers
- muliple versions
- poc (proof of concept)
- HEAD pointer points to Branch which points to latest commit on that branch
- In git the default branch is master
- Branches & Tags are considered as reference objects
- Refer Here for git branch docs from attlasian
- When we want changes from one branch to another we have the following options
- basic merge process
- checkout to the destination branch where the merge has to happen
- execute the command to merge from source
Practical branching
- initalize a new repo
- create a commit
- now view the branches
git branch
- Rename the branch from master to main
git branch -m main
- Add few more commits
- Now we will be creating a new branch
rel_v1.0
git branch rel_v1.0
- And create a commit C3

-
Lets create one more commit
-
Now merge the changes from rel_v1.0 to main
- Now lets create a branch rel_v1.1 from main
# create branch
git branch rel_v1.1
# checkout
git checkout rel_v1.1
# create a new branch & checkout
git checkout -b rel_v1.1
- create two commits “c5” and “c6” on rel_v1.1
- checkout to main and create a commit “c7”

other commands of importance
# get entire log
git log
# get last 3 commits log
git log -n 3
# get one-line history per comit
git log --oneline
Like this:
Like Loading...