Git and Github Workshop
Git and Github Workshop
Workshop
Agenda
Git : Github :
1) Introduction 1) Introduction
3) Stages 3) Pull
4) Commits 4) Push
6) Merges
What is Git?
● Git is a version control system (system for managing changes) designed to track the
development of a project.
● It provides a variety of commands that are used to save new work, revert to a
previous save and split the project into different versions (called branches)
● Thus, in a programming environment, Git is essential for teams to track the
changes in their project.
● Moreover, it makes it easier for teams to communicate with each other and work
on a project smoothly
Why use Git?
● Git is the most popular version control system (Check stackoverflow survey 2023)
● Git is a definite requirement for an entry-level programming / engineering job
● Git organizes code chronologically
● Git organizes code with the help of branches
How to download Git?
command)
Stages
1) Modify or add any file
2) git status to see the report of the new changes
3) git add fileName or git add . to stage the files
Stages are essentially files that are added to the repository, ready to be committed
Commits are the save points in your project, it is where we can observe changes between versions
A branch is a different working area from the main repository. By default, the main branch is called master.
● git branch (listes the branches in the repo, the * indicates the current branch)
● git branch -a (See all local and remote branches)
● git branch nameOfBranch (creates a new branch)
● git checkout nameOfBranch (changes the working area to a new branch)
● git log nameOfBranch (see the changes made on a branch, press “q” to come back)
Merges
1) git checkout master to come back to the main branch
2) git merge nameOfBranch to merge the branch to the master branch
2) A merge conflict prior to a merge indicates that there is a problem in the local repository (not common
to other developers)
3) When it happens after, it is because a branch is created from an initial branch and one or more file
that are in common with both branches conflict together. They conflict, because the initial branch has
changed from when the new branch was created. (conflict with another developer’s code)
4) Generally, git tries to resolve merge conflicts by its own, but when it can’t, it writes the unmerged
paths on the concerned files and the user has to fix them.
https://github.com/
Clone
1) git clone addressOfRepository to link a local repository to a GitHub repository
Creates a connection between a GitHub repository (remote repository) and a local repository.
Git pull retrieves the most recent version of the current branch we are on and overwrites it in our local
repository
● git pull
Push
Uploads the code on the current branch of a local repo to the remote repo
● git push
Pull Requests
Pull requests are made to contribute code to another developer’s repository. When creating a pull request,
the other developer is notified. They can see your commit with every new changes and decide whether or
not to accept it.
Forks Pull Requests
Creates a copy of a remote repository as one of your Pull requests are made to contribute code to another
own repos on GitHub. The original repo will not be developer’s repository.
affected by the changes on the fork. After forking a repo and making changes to it, we can
create a pull request and the other developer will be
notified.
https://www.w3schools.com/git/default.asp?remote=github
https://docs.github.com/en
https://www.atlassian.com/git/tutorials