OSDC - Cheatsheet-Git-2022 4 7
OSDC - Cheatsheet-Git-2022 4 7
Pushing changes: Sending data from your local repository to a remote repository
git remote -v View all configured remotes
git push origin HEAD Push commits located at the HEAD of your repo to the origin repo
git push origin +HEAD Push commits, forcing remote to adopt local changes
git push origin –d dev Delete dev branch from remote after pushing changes
git push origin HEAD Lastly, you push your local changes to a remote
repository, designated as origin.
git pull –-rebase <remote> <branch> Merge all commits since your last common commit
from the remote branch without a merge commit
git stash Save uncommitted changes
git stash pop Restore saved changes
git add <file> Add a file to the staging area, to be committed
git commit -m 'commit message' Most projects have a format for commit messages.
git checkout -b <new_branch> Create and checkout a branch
git checkout main && git pull --rebase Checkout and update the main branch
git reset head –-hard origin/main WARNING: Erase all local changes
git push -u origin HEAD Push your changes and the current branch to the
origin repository
git push origin HEAD Push your changes to the origin repository