Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

PS C:\Users\ayush\OneDrive\Desktop\git demo> git –version // to check version of git

PS C:\Users\ayush\OneDrive\Desktop\git demo> git clone https://github.com/AyushJainSparsh/demo.git


//to clone our repository to local system

PS C:\Users\ayush\OneDrive\Desktop\git demo> cd demo // to change directory

PS C:\Users\ayush\OneDrive\Desktop\git demo\demo> git status // to see the status of our code

PS C:\Users\ayush\OneDrive\Desktop\git demo\demo> git add demo.py // to add a particular file

PS C:\Users\ayush\OneDrive\Desktop\git demo\demo> git add . // to add all file

PS C:\Users\ayush\OneDrive\Desktop\git demo\demo> git commit -m "Adding new Fi

les" // to commit the operation locally after add

PS C:\Users\ayush\OneDrive\Desktop\git demo\demo> git push origin main // to push all the commit
code to git in main branch

PS C:\Users\ayush\OneDrive\Desktop\git demo> mkdir newDemo // to create repository by CLI

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git init // to initialise current directory to


repository

// Normally branch is set to master by default change it to main (if you want)

PS C:\Users\ayush\OneDrive\Desktop\git PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo>


git remote add origin https://github.com/AyushJainSparsh/new-demo.git //adding repository to our
directory

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git remote –v // a management tool for


your record of remote repositories

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git branch -M main // rename main branch

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git push -u origin main // pushing to main


branch

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git push // directly use push because we use


–u in last push

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git checkout -b Feature1 // moving to new


branch by creating it

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git checkout main // to move to main


branch
PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git branch -d feature1 // to delete a branch

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git diff main // to see diff between current


branch and main branch

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git pull origin main // pull commits from


main branch

PS C:\Users\ayush\OneDrive\Desktop\git demo\newDemo> git merge main // to merge current


branch with main branch

You might also like