Git Commands

most used

·

2 min read

git commandsdescription
git <branch>lists all the branches
git checkout <branch>switches to <branch>
git sudo updateit'll figure out the latest version of each package and its dependency, but will not download or install any of those updates.
git sudo upgradedownloads and installs the updates for each outdated package and dependency
git pullpulls all the latest files of the branch from remote repo
git commit -m "msg"adds log message
git commit --amend -m "new_msg"updates latest log message
git commit --amend --author="xyz <" --no-editupdates author
git config --global user.name "xyz"-
git config --global user.email "xyz@gmail.com"-
git push origin <branch>pushes changes to remote branch
git merge branch-1merges branch-1 changes to <current_branch>
git reset --soft HEAD~1Delete the most recent commit, keeping the work you've done
git reset --hard HEAD~1Delete the most recent commit, destroying the work you've done
git reset HEAD^remove commit locally
git push origin +HEADforce-push the new HEAD commit. HEAD points to the top of the current branch. git can obtain the branch name from that. So it's the same as: git push origin CURRENT_BRANCH_NAME