~ //means root directory
git --version //check version of git
ls //list items(folders/files)
clear //clear terminal
git config --global user.name "Pranjil-Singh"
git config --global user.email "
[email protected]"
git clone link //get files from repo into system
cd folderName //get inside a folder
ls -a //list all files, including hidden
git status //check for unchanged/modified/staged
git add filename OR git add . //to stage a file
git commit -m "some message" //commit, save changes
git push origin main //upload changes done to git(main-branch)
cd .. // get back to parent folder
mkdir repoName //make new directory
cd repoName //get into directory
git init //make it a git directory
git remote add origin link //to make changes to a repo in git
git remote -v //get the remote repo link
git branch //check branch
git branch -M main //change branch name
git push -u origin main //-u sets origin as default location to push so in future
type only git push
git checkout -b branchName //create new branch
git checkout branchName //goto other branch
git branch -d branchName //delete branch
*to delete branch you need to exit that branch
merge 2 ways
way 1:
git diff main //compare branch
git merge branchName //current branch gets data from branchName
way 2:
using PR(pull request) in github
git pull origin main //get content from github into local
git reset fileName //undo if only staged for one file
git reset //undo all changes for staged
git reset HEAD~1 //last commit undo
git log //see all commits
q //quit
git reset commitHash //undo commits till hash
git reset --hard commitHash //resets even the vs code files(other reset only took
the file back to modified from staged or commited)