Skip to content

Liviujmk/internship-2024-git-workshop

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Workshop


Let's learn the basics about git together.



What is vesion control?


🤔 Question: What is vesion control?


🤔 Question: When you first started to use a version control?


🤔 Question: What benefits it gave you?


🤔 Question: Does it make sense to use a version control in your personal projects?


💡 Version control, also known as source control, is the practice of tracking and managing changes to software code.

💡 If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.


What is version control? | atlassian tutorial


Version control system?


🤔 Question: What is a version control system?


🤔 Question: How many version control systems do you know?



💡 There are a lot of version control systems.

List of version-control software


💡 Some of the cool ones!


💡 Version control systems are software tools that help software teams manage changes to source code over time.

💡 Version control software keeps track of every modification to the code in a special kind of database.


15 BEST Version Control Software (Source Code Management Tools)


🤔 Question: Version control systems: distributed vs centralized. What is the difference?


💡 Centralized VCSs keep the history of changes on a central server from which everyone requests the latest version of the work and pushes the latest changes to. This means that everyone* sharing the server also shares everyone’s work.

💡 On a Distributed VCS, everyone has a local copy of the entire work’s history. This means that it is not necessary to be online to change revisions or add changes to the work.

  • Distributed VCS: Git, Mercurial.
  • Centralized VCS: CVS, Perforce, SVN.



What is git?




💡 Git is a specific open-source version control system created by Linus Torvalds in 2005 designed to handle projects with speed and efficiency.




Git based platforms



💡 There are multiple cloud platforms that are working based on git.




What is GitHub



💡 GitHub is a for-profit company that offers a cloud-based Git repository hosting service. Essentially, it makes it a lot easier for individuals and teams to use Git for version control and collaboration.




Playground

STEP 1. Create a GitHub account


Create a GitHub account


STEP 2. Get Git bash


Download Git bash

Configure Git (preferred email and username used on GitHub)

git config --global user.name "FIRST_NAME LAST_NAME"

git config --global user.email "[email protected]"



STEP 3. Set SSH key



TASK 1

👉 Fa fork si clone la proiect.

git clone [email protected]:[username]/internship-2024-git-workshop.git

👉 Verifica branch-ul local pe care te afli. Ar trebuie sa fie branch-ul "main".

git branch

👉 Fa un branch nou si da-i numele "nume-prenume/task-1".

git checkout -b nume-prenume/task-1

👉 Cu un "git branch" poti sa confirmi ca te afli pe noul branch creat local.

git branch


👉 Creeaza 3 fisiere noi.

touch pretty-1.txt pretty-2.txt pretty-3.txt pretty-4.txt

👉 Scrie in fiecare fisier urmatorul text.

I feel charming
Oh so charming
It's alarming how charming I feel
And so pretty
That I hardly can believe I'm real

👉 Verifica situatia.

git status

👉 Asa ceva ar trebui sa vezi


👉 Adauga fisierele "pretty-1.txt" si "pretty-2.txt" in gitul tau local.

git add pretty-1.txt pretty-2.txt

👉 Verifica situatia. Trebuie sa ai 2 fisiere cu verde si 2 cu rosu. Fisierele cu verde sunt in staged area.

git status

👉 Adauga un commit cu mesaj si descriere pentru fisierele tale din staged area.

git commit -m "TASK 1 | Am adaugat fisierele pretty-1.txt si pretty-2.txt"

👉 Fa push cu modificarile din git-ul tau local(staged area) pe remote(GitHub).

git push origin feature/task-1

So far so good. Primul task nu pare asa de greu.


TASK 2

👉 Verifica pe ce branch esti pe local.

git branch

👉 Inainte sa te apuci de un alt task/feature mereu sa mergi inapoi pe branch-ul local "main".

git checkout main

👉 Sterge branch-ul local "nume-prenume/task-1". Dupa ce faci merge la un branch in main, mereu sa-l stergi de pe local.

git branch -D nume-prenume/task-1

👉 Daca nu ai sters branch-ul remote(din GitHub) "nume-prenume/task-1" cand ai facut merge in "main", sterge-l acum. Mereu sa stergi branch-urile remote dupa ce le faci merge in branch-ul "main".

git push -d origin nume-prenume/task-1

👉 Mai verifica o data lista de branch-uri locale. Observa ca branch-ul "nume-prenume/task-1 " nu mai apare in lista.

git branch

👉 Inainte sa lucrezi la un nou feature, asigura-te ca branch-ul tau local "main" este la zi cu modificarile din branch-ul "main" remote(de pe GitHub). Fiind pe branch-ul "main" local, faci un git pull de pe branch-ul "main" remote.

git pull origin main

👉 Branch-ul tau local "main" fiind la zi, poti sa faci un alt branch "nume-prenume/task-2" care porneste din branch-ul "main".

git checkout -b nume-prenume/task-2

👉 Noi in task-ul anterior nu am facut commit si push la toate fisierele. Momentan mai avem doua fisiere care sunt untracked de git(au culoarea rosie).

git status

👉 Adauga ambele fisiere in git-ul tau local. De data asta in loc sa adaugam fiecare fisier in parte o sa adauga toate modificarile modificate.

git add .

👉 Asigura-te ca fisierele tale sunt cu verde, adica adaugate in staged area.

git status

👉 Adauga un commit

git commit -m "TASK 2 | Gata si task-ul 2"

👉 Fa push pe remote(pe git-ul integrat/instalat in GitHub)

git push origin nume-prenume/task-2

Gata si task-ul acesta.


Task 2 updates


Fiind un task mai complicat o sa lucreze doi developeri la el. Rezultatul final al taskului 2 este sa avem in fisierele "pretty-1.txt" si "pretty-2.txt" urmatorul text.


I feel handsome
Oh so charming
It's alarming how charming I feel
And so cool
That I hardly can believe I'm real

TASK 2.1


Pasi pentru developer 1


👉 Fa un branch "nume-prenume/task-2.1" din branch-ul "nume-prenume/task-2"


👉 Confirma ca esti pe branch-ul "nume-prenume/task-2"

git branch

👉 Fa branch-ul "nume-prenume/task-2.1"

git checkout -b nume-prenume/task-2.1

👉 In fisierul "pretty-1.txt" si "pretty-2.txt" Acceptance Criteria 1: schimba cuvantul "charming" cu "handsome". Acceptance Criteria 1: Inlocuieste randul 4 cu "++++++" Pentru task-2.1 fisierele "pretty-1.txt" si "pretty-2.txt" trebuie sa contina

I feel handsome
Oh so charming
It's alarming how charming I feel
++++++
That I hardly can believe I'm real

👉 Pune modificarile pe un branch remote

git add .
git commit -m "TASK 2.1 | Modificare 2.1"
git push origin nume-prenume/task-2.1

👉 Fa un pull request prin care vrei sa faci mergi din "nume-prenume/task-2.1" in "feature/task-2"


👉IMPORTANT: Nu da merge la pull request

TASK 2.2


Pasi pentru developer 2


👉 Fa un branch "nume-prenume/task-2.2" din branch-ul "nume-prenume/task-2"


👉 Mai intai schimba-te inapoi pe branch-ul "nume-prenume/task-2"

git checkout nume-prenume/task-2

👉 Da-i si un "git branch" ca sa confirmi

git branch

👉 Creeaza branch-ul "nume-prenume/task-2.2" din branch-ul "nume-prenume/task-2"

git checkout -b nume-prenume/task-2.2

👉 In fisierul "pretty-1.txt" si "pretty-2.txt" Acceptance Criteria 1: langa cuvantul charming adauga "and sexy" Acceptance Criteria 2: sterge randu "And so pretty" Pentru task-2.2 fisierele "pretty-1.txt" si "pretty-2.txt" trebuie sa contina

I feel charming
Oh so charming
It's alarming how charming I feel
And so cool
That I hardly can believe I'm real

👉 Pune modificarile pe un branch remote

git add .
git commit -m "TASK 2.2 | Modificare 2.2"
git push origin nume-prenume/task-2.1

Task 2 updates

👉 Fa merge la branch-ul "nume-prenume/task-2.1" in "nume-prenume/task-2"


👉 Fa merge la branch-ul "nume-prenume/task-2.2" in "nume-prenume/task-2"


👉 Rezolva conflictele.


👉 Fa merge dupa ce ai rezolvat conflictele.


Daca doriti sa aprofundati, puteti folosi urmatoarele link-uri

Git tutorial pentru incepatori
Learn git branching (With playground)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published