PROJECT MANAGEMENT (WITH GIT)
1BCSL307A
Experiment 2 - Creating and Managing Branches:
Create a new branch named "feature-branch." Switch to the "master" branch. Merge the "feature-branch" into "master."
2
Git Branching
3
BRANCHING IN VCS
4
COMMIT AND ITS TREE
5
that results from a merge of
two or more branches
$ git add README test.rb LICENSE
$ git commit -m 'Initial commit'
BRANCH IN GIT
automatically.
6
BRANCH AND ITS COMMIT HISTORY
7
CREATING A NEW BRANCH
8
hp-pc@ projects/flask-git-lab (main)
$ git branch --show-current
main
hp-pc@projects/flask-git-lab (main)
$ git branch testing
flask-git-lab (main)
hp-pc@projects/flask-git-lab (main)
$ git log --oneline --decorate
3b4e9e3 (HEAD -> main, origin/main, testing) update readme
535806a Initial flask application
hp-pc@projects/flask-git-lab (main)
$ git checkout testing
Switched to branch 'testing’
hp-pc@projects/flask-git-lab (testing)
SWITCHING TO A NEW BRANCH
9
hp-pc@projects/flask-git-lab (testing)
$ vim test.txt
hp-pc@projects/flask-git-lab (testing)
$ git add test.txt
hp-pc@projects/flask-git-lab (testing)
$ git commit -a -m 'Make other changes'
[testing 5df08dd] Make other changes
1 file changed, 1 insertion(+)
create mode 100644 test.txt
hp-pc@projects/flask-git-lab (testing)
$ git log --oneline --decorate --graph --all
* 5df08dd (HEAD -> testing) Make other changes
* 3b4e9e3 (origin/main, main) update readme
* 535806a Initial flask application
BASIC BRANCHING AND MERGING
1. Do some work on a website.
2. Create a branch for a new user story you’re working on.
3. Do some work in that branch.
At this stage, you’ll receive a call that another issue is critical and you need a hotfix. You’ll do the following:
1. Switch to your production branch.
2. Create a branch to add the hotfix.
3. After it’s tested, merge the hotfix branch, and push to production.
4. Switch back to your original user story and continue working.
10
11
BRANCHING AND MERGING
12
BRANCHING AND MERGING
13
BRANCHING AND MERGING
14
BRANCHING AND MERGING
15
BRANCHING AND MERGING
Exp 2 - Git Branching
16
Git Branching
1. Create a feature-branch
2. Switch to feature-branch
3. Create / update files
4. Stage and commit (C3 -commit)
5. Switch back to master branch
6. Merge feature-branch with master branch
7. print log, branches
8. Delete the feature-branch.
17
MERGE CONFLICTS
18
BRANCH COMMANDS
19
Experiment 2 - Creating and Managing Branches:
Create a new branch named "feature-branch." Switch to the "master" branch. Merge the "feature-branch" into "master."
20
STEPS
21
VIVA
1. Which command creates a new branch and switches to it?
A)git branch new-branch
B) git switch -c new-branch
C) git merge new-branch
D) git commit -b new-branch
2. Which command merges feature-branch into main?
3. The command used to create a new branch is __________.
4. The command used to switch to the main branch is __________.
5. What is the purpose of creating a separate feature branch in Git?
6. Which command is used to delete a merged branch?
22
VIVA - ANSWERS
23