Git and Jenkins Notes
Git and Jenkins Notes
The version control system is also known as software con guration management
(SCM) or Source code management(SCM)
Assume
Client project
| - I changed some les from the source code to meet client requirements.
| - I gave the demo and the client suggested some more changes.
| - I gave the third time demo and the client suggested some more changes.
Every version we have to maintain - one Qa maintain all the folders it's easy
20 QA are there how they maintain all the codes/ les
4. Developers have to share their code to peer developers so that multiple
developers will work in
Collaborative way.
fi
fi
fi
fi
Ranjeet Sir
Multiple versions we required to maintain each and every change should b tracked
and should be stored.
Version control system always talks about les which contain source code
1. Basic version control system terminology
where version control is not applicable, here we won't use the work like version
-1, version 2, etc
Commit: The process of sending les from the working directory to the repository
Checkout: The process of sending les from the repository to the working
directory.
fi
fi
fi
fi
fi
fi
Ranjeet Sir
Bene ts of version control system
1. We can maintain di erent versions and we can choose any version based on
client requirements.
5. Parallel development.
Git command :
Git add - sending les from the working directory to the staging area
Git Checkout - This option is performed locally via the b/w working directory and
repository. (To perform this operation n/wis not required)
Git push - The process of sending les from the local repository to the remote
repository
Git clone - To create a new local repository from the remote repository.
git pull - The process of getting the updated les from the remote repository to
the local repository.
Github
Gitlab
BitBucket
cloud perform
fi
fi
ff
fi
fi
Ranjeet Sir
Git features
1.
Distributed
Ranjeet Sir
2. Staging area
. Steps process
. First, we need to add les to the staging area and then we have to commit
from the staging area.
4. Open source
Git Architecture
fi
fi
Ranjeet Sir
1. Staging area
2. commit
3. checkout
4. Push
5. Pull
6. remote repository
7. local repository
1. Local Repository
2. Remote Repository
Ranjeet Sir
Usually, the total project code will be available in a remote repository the current
work of Qa will
Once work is completed, we have to add these les to the staging area for these
we have to use the git add command
Git add - sending les from the working directory to the staging area
Git Checkout -This option is performed locally b/w the working directory and
repository. (To perform this operation n/wis not required)
Git push - The process of sending les from the local repository to the remote
repository
Git clone - To create a new local repository from the remote repository.
git pull - The process of getting the updated les from the remote repository to
the local repository.
1. Untracked
fi
fi
fi
fi
fi
fi
Ranjeet Sir
Every new le will be created in the working directory. Git does not aware of these
new les. such types of les
2. stage
The les which are added to the staging area are said to be in a staged state
3. in repository/committed
Any le which is committed is said to be in repository state or committed state.
4.Modi ed
https://git-scm.com/download/win
it is an exe le
What is Git?
Git is a version control system tool used to track changes in computer les/source
code.
it's a tool to manage your code & le history while coordinating work remotely on
those les with others
2.
I created a new project on GitHub go ahead and clone it then continues with
your task
3.
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
Ranjeet Sir
6. Push changes to remote repo(Github) from the new branch
4.
Review code
Case 2 - Everything is good, then provide approval to merge code into the master
branch in GitHub
git pull - taking a code directly from the remote repo to the Working directory (git
fetch + merge)
git fetch - taking the code rst on local repo from remote repo(.git) and after we
need to use merge command
1)Click + and enter the repository name and click create a repository
3)To push the code on repository-->Select any particular Repository--> Copy URL
of repository(//github.com/Ranjeetkendre/12Feb_C_Morning.git)
Click search Icon and enter git repository(view) OR enter git repositories and Press
ENTER
ff
fi
fi
fi
Ranjeet Sir
9)Clone repository:
Pull URL:https:https://github.com/Ranjeetkendre/Automation_19Feb.git-->Given
by Team lead
Question :
Answer: Git is a version control system that lets you manage and keep track of
your source code history.
GitHub is a cloud-based hosting service that lets you manage Git repositories.
If you have open-source projects that use Git, then GitHub is designed to help you
better manage them.
What is Git
Git is a version control system tool used to track changes in or source code.
What is Github
Github is a hosting service for git repository.
GitHub supports code pull so anyone with access rights can pull code on a local
machine. This can also be integrated with Jenkins.
fi
fi
ff
Ranjeet Sir
GitHub supports code push so anyone with access rights can check in code in
GitHub central repository.
There arises a con ict when two separate branches have made edits to the same
line in a le,
or when a le has been deleted in one branch but edited in the other. Con icts are
most likely to happen when
Make the necessary changes in the les so that con ict does not arise again.
1. Initialize a repo
This command is used to connect your local repository to the remote server.
3. git clone
Example: navigate to your repo path where you want to clone and write the below
command in cmd
4. git log
git log
This command is used to list the version history for the current branch.
Example:
5. git merge
This command merges the speci ed branch’s history into the current branch.
fi
fi
fi
fi
ff
fl
fl
fi
fi
fi
fl
fl
fl
Ranjeet Sir
7. Git Stage Files
To stage or simply add les, you need to use the git add command. You can stage
individual les:
$ git add.
8. Git Status
If you want to see what les have been created, modi ed, or deleted, Git status will
show you a report.
$ git status
9.git commit
Example:
10. git push - After you have committed your changes, the next is to push to a
remote repository.
This command sends the committed changes of the master branch to your remote
repository.
Example:
$ git push
This command sets the author name and email address respectively to be used
with your commits.
Example:
This command fetches and merges changes on the remote server to your working
directory.
Example:
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
Ranjeet Sir
5. How to Switch Branches in Git
When you create a new branch then Git automatically switches to the new branch.
If you have multiple branches, then you can easily switch between branches with
git checkout:
Git uses multiple repositories including a centralized repository and server, as well
as some local repositories;
Git does not have the global revision number feature as SVN has.
Git was developed for the Linux kernel by Linus Torvalds; SVN was developed by
CollabNet, Inc.
Git belongs to the 3rd generation of Version Control tools; SVN belongs to the 2nd
generation of Version Control tools
7. Suppose there are 10 classes & I want to push only 5 classes, how do you
do that?
Answer: Normally we commit to git, all les are going to git but in your scenario
push only a single le git.
For this, you have to run speci c command to push the only single le to git.
Let’s take look at how to push one or two or three les to git in a single commit.
$ git commit -m "Pushing Only three les to git" con g/ le1.txt con g/ le2.txt
con g/ le3.txt
fi
fi
ff
fi
fi
ff
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
fi
Ranjeet Sir
Answer:
Github
Gitlab
Bitbucket
SourceForge
GitEnterprise
Answer: Git pull command pulls new changes or commits from a particular branch
from your central repository and updates
Git fetch is also used for the same purpose but it works in a slightly di erent way.
When you perform a git fetch, it pulls all new commits from the desired branch and
stores it in a new branch in your local repository. If you want to re ect these
changes in your target branch, git fetch must be followed with a git merge. Your
target branch will only be updated after merging the target branch and fetched
branch. Just to make it easy for you, remember the equation below:
Suppose you want to give a username and email id to associate a commit with an
identity so that you can know who has made a particular commit. For that I will
use:
git con g –global user. name “Your Name”: This command will add a username.
git con g –global user.email “Your E-mail Address”: This command will add an
email id.
It contains the collection of the les as well as the history of changes made to
those les.
fi
fi
fi
fi
fi
fi
ff
fi
fi
fl
ff
Ranjeet Sir
A repository in Git is considered your project folder.
A repository has all the project-related data. Distinct projects have distinct
repositories.
or when one person edits a le and another person deletes the same le
1. What is CI?
code in a shared repository several times a day or more frequently. Every commit
made in the repository is then built.
fl
fi
fl
fi
ff
fi
Ranjeet Sir
This allows the teams to detect the problems early. Continuous Integration is the
most important part of DevOps that
Jenkins
TeamCity
Travis CI
Go CD
Bamboo
GitLab CI
CircleCI
Codeship
AzureDevops CI-CD
Ranjeet Sir
integrate their code at a very high frequency. Teams implementing CI aim to
integrate code daily or, in some cases, even hourly.
This means that all changes to code – new features, bug xes, experiments,
con guration changes – are always ready
2. What is Jenkins?
Jenkins is an open-source continuous integration tool written in Java. It keeps a
track of the version control system and to
For each code commit changes an automatic build report noti cation generates.
To notify developers about build report success or failure, it is integrated with the
LDAP mail server.
Step 2 − in the next screen, enter the Item name, in this case, we have named it
Helloworld.
Step 3 − the following screen will come up in which you can specify the details of
the job.
2) Click “FirstJob”
8) Click (#9)
fi