Cheat Sheet of my practice and complete step by step guidance
🔸 Check my GitHub Repository 🔸
→ Click here to check by GitHub Repository
What exactly is going on here?
🔹 Git is a distributed version control system designed for tracking changes in source code during software development. It allows multiple developers to collaborate on projects, managing versions and facilitating branching for parallel development.
🔹 GitHub is a web-based platform built around Git, providing hosting for Git repositories. It enhances collaboration by offering features like issue tracking, pull requests for code review, and project management tools. GitHub is widely used for open-source projects and by teams to streamline development workflows and ensure code quality through collaboration and version control.
Installation and Login
- First of all Download Git Bash from Google Chrome by clicking on it Git Bash
- Open GitHub on chrome. Create your account via email and remember the username GitHub
Create any Repository on Github then open VS code. Open terminal on it
git config
git config --global user.name "username"
git config --global user.email "useremail"
git clone
github repository to vs code
Open Github Repository. Click on green coloured word written Code. Copy URL link of Repository.
git clone Link_of_github_repository
git clone https://github.com/thecallmeBilalAshiq/Git-and-Github.git
cd Git-and-Github
code . // to open in vs code
ls
ls -a (To see all the files, also hidden ones )
Transfer Github Repository to VS Code
git Status
git status
add is an (engagement stage)
commit is a(wedding stage)
git add
git add . // to add all new files
git add [file]
add a file as it looks now to your next commit (stage)
git commit
git commit -m "[descriptive message]"
# commit your staged content as a new commit snapshot
git commit -m "New file added"
git push
git push origin main # update from VS code to Repository
**
Stages
**
1️⃣Untracked — — we add new files, but no commit it,, it is untracked, either we write in it or not
️2️⃣Modified — — changed
3️⃣ Staged — — file is ready to be committed
4️⃣ Un-modified — — unchanged
git reset
git reset [file]
git diff
git diff
# diff of what is changed but not staged
git diff - staged
# diff of what is staged but not yet commited
git log
→ to see all commmits
git log
git remote
git remote add origin https://github.com/thecallmeBilalAshiq/LocalRepo.git
git remote -v
♀️ Detail about Branches♀️
git branch
git branch
git branch -m new_name(rename the branch)
Instead of it you can use it.
git push -u origin main
-> Write previous line for one times then you can only run this command.
git push
git checkout
git checkout -b newbranch # to create new branch
git checkout newbranch # for shifting to different branches)
Delete a branch
git branch -d bilalbranch ==> delete
Merge branches
Method 01:
git diff main # to check the difference between two branches
git merge main # to merge new branch with the main branch
Method 02 — via github
PR (Pull Request)
after merging on github - ->
git pull origin main
to update it on your computer.
Undo anything, Undo any commit
git reset
git reset
git reset HEAD~1 ==> to undo last commit
git reset
Fork
Fork on github to get other people repositories
Search their repository -> fork it -> complete
-> now that person repository is your repository
🔵 → Certification ← 🔵
Certificate of Introduction to Git and GitHub course from Google Coursera
Completion Certificate for Introduction to Git and GitHub
This certificate verifies my successful completion of Google's "Introduction to Git and GitHub" on Coursera
coursera.org
Top comments (0)