Project Management With Git - (BCS358C) DEC - 2023
Project Management With Git - (BCS358C) DEC - 2023
3/1/2024 ELAIYARAJA P
BCS358C-
Project Management with Git
Version Control with Git, 3rd Edition, by Prem Kumar Ponuthorai, Jon Loeliger Released October 2022,
Publisher(s): O'Reilly Media, Inc.
● Pro Git book, written by Scott Chacon and Ben Straub and published by Apress, https://gitscm.
com/book/en/v2
● https://infyspringboard.onwingspan.com/web/en/app/toc/lex_auth_0130944433473699842782_shared
/overview
● https://infyspringboard.onwingspan.com/web/en/app/toc/lex_auth_01330134712177459211926_share
d/overview
1154..0099..22002233
(As per VTU Syllabus)
3/1/2024 ELAIYARAJA P
Program Outcomes:
PROGRAM OUTCOMES
PO's PO Description
Engineering knowledge: Apply the knowledge of mathematics, science, engineering
PO1 fundamentals, and an engineering specialization to the solution of complex
engineering problems.
Problem analysis: Identify, formulate, review research literature, and analyze
PO2 complex engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering sciences.
Design/development of solutions: Design solutions for complex engineering
problems and design system components or processes that meet the specified needs
PO3
with appropriate consideration for the public health and safety, and the cultural,
societal, and environmental considerations.
Conduct investigations of complex problems: Use research-based knowledge and
PO4 research methods including design of experiments, analysis and interpretation of
data, and synthesis of the information to provide valid conclusions.
Modern tool usage: Create, select, and apply appropriate techniques, resources, and
PO5 modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.
The engineer and society: Apply reasoning informed by the contextual knowledge
PO6 to assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
Environment and sustainability: Understand the impact of the professional
PO7 engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
Ethics: Apply ethical principles and commit to professional ethics and
PO8
responsibilities and norms of the engineering practice.
3/1/2024 ELAIYARAJA P
Program Outcomes:
Individual and team work: Function effectively as an individual, and as a member
PO9
or leader in diverse teams, and in multidisciplinary settings.
Communication: Communicate effectively on complex engineering activities with
the engineering community and with society at large, such as, being able to
PO10
comprehend and write effective reports and design documentation, make effective
presentations, and give and receive clear instructions.
Project management and finance: Demonstrate knowledge and understanding of
the engineering and management principles and apply these to one’s own work, as a
PO11
member and leader in a team, to manage projects and in multidisciplinary
environments.
Life-long learning: Recognize the need for, and have the preparation and ability to
PO12 engage in independent and life-long learning in the broadest context of technological
change.
3/1/2024 ELAIYARAJA P
Program Specific Outcomes:
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
CREDITS – 1
CIE (Continuous Internal Evaluation) MARKS – 50
SEE (Semester End Examination) MARKS – 50
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Course objectives(CO):-
➢ To familiar with basic command of Git
➢ To create and manage branches
➢ To understand how to collaborate and work with Remote Repositories
➢ To familiar with version controlling commands
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Course Outcomes:
• Use the basics commands related to git repository
• Create and manage the branches
• Apply commands related to Collaboration and Remote Repositories
• Use the commands related to Git Tags, Releases and advanced git
operations
• Analyse and change the git history
3/1/2024 ELAIYARAJA P
BCS358C-Project
Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
What is Git?
3/1/2024 ELAIYARAJA P
Introduction to GIT
Git is a distributed version control system (VCS) that is widely used for
tracking changes in source code during software development. It was
created by Linus Torvalds in 2005 and has since become the de facto
standard for version control in the software development industry.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
Introduction to GIT
▪ Repository (Repo): A Git repository is a directory or storage location where your
project's files and version history are stored. There can be a local repository on
your computer and remote repositories on servers.
▪ Commits: In Git, a commit is a snapshot of your project at a particular point in
time. Each commit includes a unique identifier, a message describing the
changes, and a reference to the previous commit.
▪ Branches: Branches in Git allow you to work on different features or parts of your
project simultaneously without affecting the main development line (usually
called the "master" branch). Branches make it easy to experiment, develop new
features, and merge changes back into the main branch when they are ready.
3/1/2024 ELAIYARAJA P
Introduction to GIT
▪ Pull Requests (PRs): In Git-based collaboration workflows, such as GitHub or GitLab,
pull requests are a way for developers to propose changes and have them reviewed by
their peers. This is a common practice for open-source and team-based projects.
▪ Merging: Merging involves combining changes from one branch (or multiple
branches) into another. When a branch's changes are ready to be incorporated into the
main branch, you can merge them.
▪ Remote Repositories: Remote repositories are copies of your project stored on a
different server. Developers can collaborate by pushing their changes to a remote
repository and pulling changes from it. Common remote repository hosting services
include GitHub, GitLab, and Bitbucket.
3/1/2024 ELAIYARAJA P
Introduction to GIT
3/1/2024 ELAIYARAJA P
Features to GIT
❑ Version Control
❑ Collaboration
❑ Branching
❑ Distributed Development
❑ Backup and Recovery
❑ Code Review
❑ Open Source and Community Development
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
https://git-scm.com/download/win
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Select Additional
icons &
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Next
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Install
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Click on
Finish
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Type
▪ git --version
You can view the
version which is
installed in the
system
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Type
▪ git init
You can
initialize git
repository
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To set your username, type and execute these commands:
• git config --system user.name "gitlab"
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To set your username, type and execute these commands:
• git config --system user.email “[email protected]"
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
You can check in C:\Program Files\Git\etc
Open gitconfig
Using notepad once
and you can able to
view in the master
User name
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Create directory
• mkdir gitlab
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Type
• git commit
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Type
Some content
Press Esc key
Type
:wq to save.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Type
• git log
to check your logs
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Step 2 – Create a repository
You can click on the + symbol on the top right corner of the page then choose "New
repository". Give your repo a name then scroll down and click on "Create repository".
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Step 2 – Create a repository
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Basic commands
git init: Initializes a new Git repository in the current directory.
git clone <repository URL>: Creates a copy of a remote repository on your local
machine.
git add <file>: Stages a file to be committed, marking it for tracking in the next
commit.
git commit -m "message": Records the changes you've staged with a descriptive
commit message.
git status: Shows the status of your working directory and the files that have been
modified or staged.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
git log: Displays a log of all previous commits, including commit hashes, authors, dates,
and commit messages.
git diff: Shows the differences between the working directory and the last committed
version.
git branch: Lists all branches in the repository and highlights the currently checked- out
branch.
git branch <branchname>: Creates a new branch with the specified name.
git checkout <branchname>: Switches to a different branch.
git merge <branchname>: Merges changes from the specified branch into the currently
checked-out branch.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 1 :
Setting Up and Basic Commands
Initialize a new Git repository in a directory. Create a new file
and add it to the staging area and commit the changes with an
appropriate commit message.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
$ git init
1. Create a new file in the directory. For example, let's create a file named "my_file.txt."
You can use any text editor or command-line tools to create the file.
2. Add the newly created file to the staging area. Replace "my_file.txt" with the actual
name of your file:
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Your commit message should briefly describe the purpose or nature of the changes you made. For example:
After these steps, your changes will be committed to the Git repository with the provided commit message.
You now have a version of the repository with the new file and its history stored in Git.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 2 :
Creating and Managing Branches
Create a new branch named "feature-branch." Switch to the
"master" branch. Merge the
"feature-branch" into "master."
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Creating and Managing Branches:
Create a new branch named "feature branch.”Switch to the" master" branch. Mergethe "feature-
branch" into "master."
Solution:
To create a new branch named "feature-branch," switch to the "master" branch, and mergethe "feature-branch"
into "master" in Git, follow these steps:
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
This command will create a new branch called "feature-branch" and switch to it.
1. Make your changes in the "feature-branch" by adding, modifying, or deleting files
as needed.
2. Stage and commit your changes in the "feature-branch":
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
git add .
$ git commit -m "Your commit message for feature-branch"
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Now, your changes from the "feature-branch" have been merged into the
"master" branch.Your project's history will reflect the changes made in
both branches
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 3 :
Creating and Managing Branches
Write the commands to stash your changes, switch
branches, and then apply the stashed
changes.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Write the commands to stash your changes, switch branches, and then apply the stashed changes.
Solution:
To stash your changes, switch branches, and then apply the stashed changes in Git, you canuse the
following commands:
This command will save your changes in a stash, which acts like a temporary storage forchanges that
are not ready to be committed.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. Switch to the desired branch:
Replace "target-branch" with the name of the branch you want to switch to.
This command will apply the most recent stash to your current working branch. If you have multiple
stashes, you can specify a stash by name or reference (e.g., git stash apply stash@{2}) if needed.
If you want to remove the stash after applying it, you can use git stash pop instead of git stashapply.
Remember to replace "Your stash message" and "target-branch" with the actual message you want for your
stash and the name of the branch you want to switch to.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 4 :
Collaboration and Remote Repositories:
Clone a remote Git repository to your local machine.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
2. Navigate to the directory where you want to clone the remote Git repository. You can use the cd
command to change your working directory.
3. Use the git clone command to clone the remote repository. Replace <repository_url> with the URL
of the remote Git repository you want to clone. For example, if you were cloning a repository from
GitHub, the URL might look like this:
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. Git will clone the repository to your local machine. Once the process is
complete, you will have a local copy of the remote repository in your
chosen directory.
You can now work with the cloned repository on your local machine, make
changes, and push those changes back to the remote repository as needed.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 5 :
Collaboration and Remote Repositories:
Fetch the latest changes from a remote repository and
rebase your local branch onto the updated remote branch.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. Fetch the latest changes from the remote repository. This will update your local
repository with the changes from the remote without merging them into your local
branch:
Here, origin is the default name for the remote repository. If you have multiple remotes,
replace origin with the name of the specific remote you want to fetch from.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. Once you have fetched the latest changes, rebase your local branch onto the updated remote
branch:
Replace <branch-name> with the name of the remote branch you want to rebase onto. This
command will reapply your local commits on top of the latest changes from the remote branch,
effectively incorporating the remote changes into your branch history.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. Resolve any conflicts that may arise during the rebase process. Git will
stop and notify you if there are conflicts that need to be resolved. Use
a text editor to edit the conflicting files, save the changes, and then
continue the rebase with:
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
1. After resolving any conflicts and completing the rebase, you have successfully updated your local branch
with the latest changes from the remote branch.
2. If you want to push your rebased changes to the remote repository, use the git push command. However, be
cautious when pushing to a shared remote branch, as it can potentially overwrite other developers' changes:
Replace <branch-name> with the name of your local branch.By following these steps, you can keep your
local branch up to date with the latest changes from the remote repository and maintain a clean and linear
history through rebasing.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 6
Collaboration and Remote Repositories:
Write the command to merge "feature-branch" into
"master" while providing a custom commit message for the
merge.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To merge the "feature-branch" into "master" in Git while providing a custom commit message for the
merge, you can use the following command:
Replace "Your custom commit message here" with a meaningful and descriptive commit message for
the merge. This message will be associated with the merge commit that is created when you merge
"feature-branch" into "master."
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
EXPERIMENT 7.
Git Tags and Releases:
Write the command to create a lightweight Git tag named
"v1.0” for a commit in your local repository.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To create a lightweight Git tag named "v1.0" for a commit in your local repository, you can use the
following command:
This command will create a lightweight tag called "v1.0" for the most recent commit in your current
branch. If you want to tag a specific commit other than the most recent one, you can specify the
commit's SHA-1 hash after the tag name. For example:
Replace <commit-SHA> with the actual SHA-1 hash of the commit you want to tag.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Experiment 8.
Advanced Git Operations:
Write the command to cherry-pick a range of commits
from "source-branch" to the current branch.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To cherry-pick a range of commits from "source-branch" to the current branch, you can use the following command:
Make sure you are on the branch where you want to apply these changes before running the cherry-pick command.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Experiment 9.
Analysing and Changing Git History:
Given a commit ID, how would you use Git to view the
details of that specific commit, including the author, date,
and commit message?
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To view the details of a specific commit, including the author, date, and commit message,
you can use the git show or git log command with the commit ID. Here are both options:
bash
git show <commit-ID>
Replace <commit-ID> with the actual commit ID you want to view. This command will
display detailed information about the specified commit, including the commit message,
author, date, and the changes introduced by that commit.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
For example:
The -n 1 option tells Git to show only one commit. Replace <commit-ID> with the actual commit
ID. This command will display a condensed view of the specified commit, including its commit
message, author, date, and commit ID.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
For example:
$ git log -n 1 abc123
Both of these commands will provide you with the necessary information about
the specific commit you're interested in.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Experiment 10.
Analysing and Changing Git History:
Write the command to list all commits made by the author
"JohnDoe" between "2023- 01-01"and "2023-12-31."
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To list all commits made by the author "JohnDoe" between "2023-01-01" and "2023-12-
31" in Git, you can use the git log command with the --author and --since and --until
options. Here's the command:
This command will display a list of commits made by the author "JohnDoe" that fall
within the specified date range, from January 1, 2023, to December 31, 2023. Make sure
to adjust the author name and date range as needed for your specific use case.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Experiment 11.
Analysing and Changing Git History:
Write the command to display the last five commits in the
repository's history.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To display the last five commits in a Git repository's history, you can use the git
log command with the -n option, which limits the number of displayed commits.
Here's the command:
$ git log -n 5
This command will show the last five commits in the repository's history. You
can adjust the number after -n to display a different number of commits if
needed.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
Experiment 12.
Analysing and Changing Git History:
Write the command to undo the changes introduced by the
commit with the ID "abc123".
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
To undo the changes introduced by a specific commit with the ID "abc123" in Git, you can
use the git revert command. The git revert command creates a new commit that undoes the
changes made by the specified commit, effectively "reverting" the commit.
Here's the command:
Replace "abc123" with the actual commit ID that you want to revert. After running this
command, Git will create a new commit that negates the changes introduced by the specified
commit. This is a safe way to undo changes in Git because it preserves the commit history
and creates a new commit to record the reversal of the changes.
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
3/1/2024 ELAIYARAJA P
BCS358C-Project Management with Git
THE END
3/1/2024 ELAIYARAJA P