Skip to content

Welcome to the Git & GitHub Notes πŸ“— repository! πŸš€ Explore the world of version control and collaborative software development with comprehensive notes on Git and GitHub.πŸ’š

Notifications You must be signed in to change notification settings

parthmern/Git-and-Github

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 

Repository files navigation

Git-and-Github

❀️ What is Git ?

βž” Free and openSource version control system ( vcs means tools that help to track changes in code )
βž” VCS track history and it helps to collaborate

❀️ What is GitHub ?

βž” Website where we host repositories online
βž” we can also track our initiate , update , delete history.
βž” generally we create files/folders using mouse but we can create them using terminal. Likewise, we can directly upload on github but a good developer prefer to do changes using Terminal.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’š Using Git

βž” Git is already installed in macOs and Linux. But, in windows we are installing Git-Bash which already have git
βž” check that git installed or not git --version if any version available then git is installed

βž” ways to use git

  1. Command line -- popular way
  2. IDE/code editors like VScode
  3. Graphical user interface like GitKraken

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠️Note- everywhere in codes if i am using means you have to write proper thing at something expect < , > like " <name> " so the answer of this is "parth"


━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’› Configuring Git

βœ”οΈ git config --global user.name "<userName>" (write username at userName)
βœ”οΈ git config --global user.email "<[email protected]>" (enter your email)
βœ”οΈ git config --list (to check that details are saved or not )

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’™ Git with VScode

βž” we can also open intergrated terminal with vscode (From the menu, use the Terminal > New Terminal or View > Terminal menu commands)
βž” same as terminal/git-bash

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’š Basic commands

βœ”οΈ git clone <link> = clone = cloning a repository on our local machine
πŸ’€ how to generate links - go to the repo on gitHub and there is button named CODE click there and copy HTTPS link

βœ”οΈ git status = status = display the state of code

βœ”οΈ git add <fileName> = adds new or changed files in working directory to the git staging area
βœ”οΈ git commit -m "some message" = record the change
βœ”οΈ git push origin main = upload local repo content to remote repo

♻️ first clone the github repo on local machine , then check git status , if any file which created newly is untracked then do git add then if we do some changes in that file then again do git commit means save , then if we want to push/upload this file on github then do git push origin main

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’œ Init command - used to create new git repo

βž” sometimes we started to create project from scratch in our local system and if we want to make new repo then

βœ”οΈ git init =
βœ”οΈ git remote add origin <link> = we are adding the link of repo where we want to push our folders from local system
βœ”οΈ git remote -v = to verify remote
βœ”οΈ git branch = to check branch name
βœ”οΈ git branch -M main = to rename branch name to "main"
βœ”οΈ git push origin main

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’š Git branches

βž” it creates the duplicate of main/master branch to work on features or fix bugsv

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’š branch commands

βœ”οΈ git branch = to check branch
βœ”οΈ git branch -M main = to rename branch
βœ”οΈ git checkout <branch-name> = to navigate
βœ”οΈ git checkout -b <new-branch-name> = to create new branch
βœ”οΈ git branch -d <branch-name> = to delete branch

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’› Merging code

βž” merging branches

βœ”οΈ git diff <branch-name> = to compare commits,branches,files
βœ”οΈ git merge <branch-name> = to merge 2 branches

OR create a PR(Pull Request)

πŸ’™ Pull Request
βž” it lets you tell others about the changes you have pushed to a branch in a repo on github
βž” we can get the button "Compare & pull request" of PR at the github repo for merging

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🧑 Pull command

βž” Now the changes are already done on github using PR from github web and so there is not any changes on our local working system and so we have to do Pull command to see the same repo as github ( first push and then pull )
βœ”οΈ git pull origin main

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’› Merge conflicts

βž” like we have 2branches and at the same place there are different chnages available and so there is conflict
βž” Vs code already have feature it will ask about it and then you have to select the changes or that is your wish what will be the change

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’š Fixing Mistakes

1️⃣ Staged (git status) changes
βœ”οΈ git reset <fileName> (for remove change the particular file)
βœ”οΈ git reset (for remove the change for all files)

2️⃣ commited changes(for one commit)
βœ”οΈ git reset HEAD~1 (here head pointer is pointing last commit)

3️⃣ commited changes(for many commits)
βœ”οΈ git reset <commit-hash>
βœ”οΈ git reset --herd <commit-hash>

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

πŸ’› What is Forking ?

βž” a fork is newrepo that shares code and visibility settings with original "upstream" repo
βž” fork is rough copy
βž” usage- open source contribution

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

differance

git diff

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

revert to previous version

VvIxF 1_045T7UdsT40cRIwCAnUJ0w

https://stackoverflow.com/questions/19032296/how-to-use-git-revert

git log

git log --oneline

git revert <versionId>
git reset <versionId> 

βœ”οΈπŸ’š cheatSheet

♻️ @ Created by Parth with πŸ’š

About

Welcome to the Git & GitHub Notes πŸ“— repository! πŸš€ Explore the world of version control and collaborative software development with comprehensive notes on Git and GitHub.πŸ’š

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published