Professional Documents
Culture Documents
Code Versioning With GIT
Code Versioning With GIT
Code Versioning With GIT
www.newpharma-development.ro
Agenda Code versioning
What is GIT ?
GIT Operations
GIT Flavors
Demo
www.newpharma-development.ro
Code versioning
Version Control
• software practice for managing and tracking changes to software
code
www.newpharma-development.ro
Code versioning
www.newpharma-development.ro
Code versioning
www.newpharma-development.ro
Code versioning
www.newpharma-development.ro
What is GIT ?
www.newpharma-development.ro
What is GIT ?
GIT
free and open-source distributed version control system
designed to handle everything from small to very large projects
with speed and efficiency.
www.newpharma-development.ro
www.newpharma-development.ro
Install GIT
• https://git-scm.com/downloads
• https://git-scm.com/downloads/guis
www.newpharma-development.ro
GIT Environment Setup
Git supports a command called git config that lets you get and
set configuration variables that control all facets of how Git
looks and operates.
www.newpharma-development.ro
GIT Operations
www.newpharma-development.ro
GIT basics - Getting a git repository
www.newpharma-development.ro
GIT Initialize a repository
www.newpharma-development.ro
GIT – Get a remote repository
Example:
git clone git@github.com:grafana/grafana.git
git clone https://github.com/grafana/grafana.git
www.newpharma-development.ro
GIT Basic Workflow
www.newpharma-development.ro
GIT – Working with Branches
www.newpharma-development.ro
GIT – Working with Branches
www.newpharma-development.ro
GIT – Working with Branches
www.newpharma-development.ro
GIT – Conflict
When two branches are trying to merge, and both are edited
at the same time and in the same file, Git won't be able to
identify which version is to take for changes. Such a situation
is called merge conflict.
The branch or commit you are on (checkout) is called „Yours”
or „Mine” or „Local”, or synonyms
The branch or commit you are merging with (commits from it
come to your current branch) is called „Theirs” or „Server”, or
synonyms
NEVER resolve a conflict „using mine” or „using theirs”. You
are throwing away code that has a reason for being there
www.newpharma-development.ro
GIT – Add and Commit
To have git track changes of a file, you first create the file
and then run `git add filename`.
To attach a history for that file in the branch that you are
on, locally, you use `git commit -m „Message for this
commit”`.
Each commit is a snapshot of the entire project.
When you add a file to a commit it is called „staged”.
When you commit a file we call it „committed”
www.newpharma-development.ro
GIT – Pushing and pulling
www.newpharma-development.ro
GIT – Status
www.newpharma-development.ro
GIT – Diff
Git diff - lists out the changes between your current working
directory and your staging area
www.newpharma-development.ro
GIT – Log
You can see a log of all commits ever made on the branch
you are on
To do this, run `git log`
You’ll see
• the commit hash (unique)
• Author
• Date
• Commit message
www.newpharma-development.ro
GIT – gitignore
www.newpharma-development.ro
Merge Request vs Pull Request
www.newpharma-development.ro
GIT Flavors
www.newpharma-development.ro
Git Flavors
www.newpharma-development.ro
Resources
• https://learngitbranching.js.org/
• http://gitreal.codeschool.com/levels/1
• https://testautomationu.applitools.com/git-tutorial/
• https://education.github.com/git-cheat-sheet-
education.pdf
www.newpharma-development.ro
Homework
• Create a Github/Gitlab account
• Create a public repository for a new project called:
devopscademy
• Add the previous homework files to the main branch and push
them into the repository, with commit message "Homework
from module 2 and 3"
• Create a branch called develop from main branch, modify the
shell script from linux module to display your RAM on Linux,
commit the changes with message "Display available RAM" and
push the develop branch to the remote repository.
• Create a merge request/pull request between develop and main
branch
• Send the repository URL via email hello@newpharma-
development.ro
www.newpharma-development.ro
Thank you!
www.newpharma-development.ro