git init | To Initialize a Repository |
git add <file name> | To add a single file |
git add . | To add all files to the Repository |
git status | To view a status |
git commit -m "type you message here" | To commit with a message |
git clone <repourl> | To clone the repo |
git pull | To pull the changes to a local repository |
git push | To push the local changes to a remote repository |
git branch <name of the branch> | To create a new branch |
git branch | To see available branches |
git checkout <name of the branch> | To switch branch |
git branch -b <name of the branch> | To create and checkout into that branch |
git switch <name of the branch> | To switch branch |
git switch - | To switch to the previous branch |
git switch -c <name of the branch> | To create and switch to the branch |
git log | To view over all history of the project |
git remote add origin <url> | To add personal url or repo to local |
git remote add upstream <url> | To add upstream url or repo to local |
git push origin <branch name> -f | To force push commits |
git fetch --all --prune | To fetch changes |
git reset --hard upstream/main | To reset the main branch of the origin to the main branch of upstream |
git pull upstream main | To reset main branch of the origin to the main branch of upstream |
git rebase -i <git log code> | squashing commits |
git reset --hard HEAD^ | To remove the last commit |