M astring Version Control

Courses

Video 01: Introduction & What's the Version Control

يعني ايه version control ؟
لو عندك تيم في شركة مثلا محتاج يشتغل علي بروجيكت واحد في نفس الوقت
الي هيحصل هتلاقيهم هيشتغل بشكل توازي يعني واحد واحد يشتغل عليه هيجي اول واحد يمسك البروجيكت يخلص الجزئ الي مطلوب منه وبعد كده يديه للتاني يخلص الي عليه وبعد كده يديه للثالث وهكذا
الحركة ده فاشلة جدا لان بعيدا ان كده البروجيكت ده قدامه سنة عقبال ميخلص بالمنظر ده انت كمان لو لقيت مشكلة في البروجيكت مش هتعرف تصلحها بسهولة ومش هتبقي عارف مين الي عمل المشكلة
الي version control system مهم ليه بقي لانه بيسهل جدا ان تيم كامل يشتغل مع بعضه علي نفس البروجيكت ويكون كل المفات موجودة في سيرفر منفصل كله يقدر يوصله وكل واحد بياخد نسخة عنده يعمل الي مطلوب منه ويرفعها تاني والتيم ليدر يبص علي التعديلات ويأما يوافق عليها وتتضاف يأما يرفضها وتتعاد تاني ويبقي معروف كل واحد عمل ايه وامتي وتقدر ترجع لاي اصدار من البروجيكت وتقدر في اي وقت تشيل تعديل كامل علي بعضه بسهولة

طيب عندنا بقي ثلاث انواع من ال version control
النوع الاول Local version control (LVC)
النوع الثاني Centralized version control (CVC)
النوع الثالث Distributed version control (DVC)

اول نوع LVC
حاجة ليك انت وعلي جهازك وبس
بيتحفظ فيه التعديلات الي انت بتعملها علي الملفات بتاعتك علي جهازك بس
وده وظيفته انه يوريك زي مقارنة مبين الملفات الي كانت موجودة الاول والملفات بعد مانت عدلت عليها
بس فيها عيب خطيير وهو ان لو حصل مشكلة في الهارد او الداتا بيز فانت كده خسرت كل الملفات الي انت اشتغلت عليها

ثاني نوع CVC
وده معناه انه بيبقي عندك فايل واحد عليه كل الاصدارات والتعديلات وهنا كل واحد من تيم بيرفع تعديلاته علي السيرفر ده والتيم ليدر هو الي بيوافق هو يرفض التعديلات ده
وده برده فيه عيب انه كل الملفات بتبقي علي سيرفر واحد بس فلو حصل مشكلة فيه برده الملفات كله هطير

النوع الثالث بقي DVC
وده بقي بيدمج النوعين الي فاتو مع بعض وهنا البروجيكت بيبقي موجود علي السيرفر ولما حد يحب يعدل عليه بياخد نسخة من الملفات ده عنده علي الجهازه يعدل عليه بس بيبقي ماذال علي تواصل مع السيفر فلو حد عدل علي الملفات الي علي السيفر فوقتها مش هتبقي محتاج تاخد نسخة تاني من الملفات لا بتعمل حاجة اسمها pull علشان يظهرلك الملفات الي اتعدل عليها بس وبعد مبتخلص التعديلات الي انت بتعمله بترفع التعديلات الي انت عملتها بس علي السيرفر
ايه بقي اشهر DVC بقي ايوة هو ال git

ال git بقي ظهر امتي
ظهر git في سنة 2005 والي انشأه هو Linus Torvalds واه هو الي عمل اللينكس المهم كانوا بيستخدموا في تطوير اللينكس حاجة اسمها BitKepper وده عبارة برده عن version control من النوع DVC
المهم بقي في سنة 2005 لغت BitKeeper الخدمة المجانية بتاعتها
وده الي خلا linus في خلال 12 يوم بس انه يعمل git

كلمات هتسمها في الكورس ده فسيرش عليها
Repository
Branch
Local repo
Remote repo
Commit
Clone
Push
Pull
Pull Request
Shell
Terminal
CMD
Powershell

Video 02: CMD Basics

Use color with number to change the color of the cmd

If you write "color" only this will change to default

color

You can use --help to see more information

color --help

Change the title of cmd

title kareem

Change directory

& Use cd.. to return back

cd YOURFOLDERNAME

cd ..

Clear Screen

- ctrl + l

- clear

- cls

Show current directory

pwd

Know more information about any command use --help

ls --help

Know the name of user

whoiam

Video 03: Paths and folders

Create new folder

mkdir THENAMEOFTHEFOLDER

Open the folder on windows explorer

explorer .

Show files on your directory

ls
 
dir

Move folder to another

If the second folder in not exist move will rename folder

move folder_1 folder_2

Rename folder

rename folder_x folder_z

Delete a folder

rm -r folderName

Print message on the console

echo "Hello World"

And if you need to add this text on file use >

echo "Hello World" > text.txt

Note: echo overwrite the old text with new text (remove old text), and if you need to not remove old text use >>

echo "Hello World" >> text.txt

Make a new file

touch text.txt

Copy file

cp 1.txt 2.txt

for loop, syntax:

for /l %i in (START, INCREMENT, END) do 

making 20 folder

for /l %i in (1, 1, 20) do mkdir folder%i

Video 04: Dealing with Texts

Show text that is inside the file

cat text.txt

Show the first 10 lines of the file

head file.txt

Show the number of lines you need

head -n 15 file.txt

Show the latest 10 lines from the bottom

tail file.txt

Show to number of lines you need from bottom

tail -n 15 file.txt

Edit the file

nano file.txt

Find text at many files and folders

grep "text" -r

Copy any thing just write | clip

ipconfig | clip

Do two command on the same time use &&

ipconfig && mspaint

Video 05: Git basics and modify the configuration

Make any change globally

--global

Know the list of config

git congfig --list
 
git config -l

For example to show your name

git config --global user.name

and to edit it write your name after the following command

git config --global user.name "Kareem"

and show your email

git config --global user.email

and to edit it write your email after the following command

git config --global user.email "YOUREMAIL@gmail.com"


Start using git on the folder

git init

Know the status of the project

git status

Add file to staging area (use * to add all files)

git add *
 
git add --all
 
git add -A

Add files to local repo

git commit -m "COMMITDESCRIPTION"

Add the branch

git branch -M main
 
git remote add origin https://github.com/GITHUBUSERNAME/REPONAME.git

Push to remote repo

git push -u origin main

Show all commits on the project

git log
 
git log --oneline

Video 06: cloning and Learn Pull Requests

Pull from remote repo to local repo

git pull origin main

When modifying on a file, If you want to see the changes before staging area

git diff

Return files from staging area to working directory

git restore --staged index.html
 
git rm --cached *

Show all commits on the project

git log
 
git log --oneline

Deleting a commit after push it to remote repo, it delete all commit after the head commit

git reset --hard IDOFTHESECONDCOMMIT

Changing the name of the latest commit

git commit --amend -m "NEWCOMMITDESCRIPTION"

Clone repo from github to local

git clone https://github.com/GITHUBUSER/REPONAME.git

Video 07: All About Aliases

You can make an alias for a long command to write it fast

git config --global alias.YOURALIASNAME THECOMMAND

for example

git confog --global alias.st status

Deleting Alias

git config --global --unset alias.ALIASNAME

for example

git config --global --unset alias.st

Edit all configurations

git config --global --edit

Exit Vim

:wq

Change text editor to Nano

First open .gitconfig file

[core]
    editor = nano

Change text editor to Vs code

[core]
    editor = "code --wait"

Return text editor to default (Vim)

[core]
    editor = vim

Video 08: Branching and merging

Show all branches

git branch

Add new branch

git branch BRANCHNAME

Convert to the new branch

git checkout BRANCHNAME
 
git switch BRANCHNAME

Create new branch and convert into it

git checkout -b BRANCHNAME

Delete branch

git branch -d BRANCHNAME

Rename branch

git branch -m NEWBRANCHNAME

Send branch to remote repo

git push origin BRANCHNAME

Merge the main branch with the new branch

git merge BRANCHNAME

Video 09: All About Stash

If there are files at staging area and you don’t want to push it ,here using stash to keep it out

git stash

List all stashes and show their IDs

git stash list

Stash file with description

git stash save "Your description"

Return stash and delete it

git stash pop

Note: it returns latest stash you have

If you need to return specific stash

git stash pop stash@{IDNUMBER}

Return stash without deleting it

git stash apply

Delete stash

git stash drop

Show what’s inside the stash

git stash show

Delete all stashes you have

git stash clear

Video 10: All about Tagging And Releasing

Showing all tags

git tag

Add new tag

git tag v1.0
 
git push origin v1.0

Note: this will take the description from your commit


Add new tag with different description

git tag -a v1.0 -m "Your description"
 
git push origin v1.0

Delete tag locally

git tag -d v1.0

delete tag remotely

git push origin --delete v1.0