Git & Githubs Commands

Terminal Commands 

cd      (go to child directory)
cd ..   (go to parent)
mkdir   (create a new folder)
ls      (list of files)
ls -a   (show also hidden files)  
 

Check Git Version

git --version

Configuring Git

git config --global user.name "myname" git config --global user.email "mailId" git config --list (to check git config)
 

Clone & Status

Clone - Cloning a repository on our machine

git clone <-link-> git status

Add & Commit

git add filename git add . (when we use dot then added all files) git commit -m "msg"

Git Push

upload local repo content to remote repo git push origin main

Init Command

used to create a new git repo git init git remote add origin <-link-> git remote - v (to verifiy remote) git branch (to check branch) git branch -M main (to rename branch)

git push origin main 
  or
git push -u origin main         (-u set origin main) 

WorkFlow

GitHub repo > clone > changes > add > commit > push

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

Way 1

git diff (to compare commits, branches,files & More) git merge (to merge 2 branches)

Way 2

Create a PR

Pull Req

git pull origin main

Git Merge

git merge


Undoing Changes

Case 1 : Staged Changes

git reset <-file name - > git reset

Case 2 : commit changes (for one commit)

git reset HEAD~1

Case 3 : Commited changes (for many commits)

git reset <-commit hash->
git reset--hard <-commit hash->

Watch Tutorial

Fork

A fork is a new repository that shares code and visibility settings with thee original "upstream" repository. Fork is a rough copy.

Comments

Popular posts from this blog

Angular Interview Question | Top Interview Question | angular

web designing(polytechnic bteup) exam papers PGDCA download