Push command is used to upload local repository content to a remote repository. When you have made changes to your local repository (such as new commits) and want to share those changes with others or save them on a remote server, you use git push.

Push a commit

To push the current staged changes you can use:

git push
Bash

To edit the last commit you can use:

git commit --amend
Bash

And you have to use force push incase you need to push the edited commit to the remote repo.

git push --force
Bash


Delete Pushed commit

To delete the last commit that has been pushed to the remote repo

git reset --hard HEAD~1
git push origin --force HEAD
Bash

If you want to delete the last five commits

git reset --hard HEAD~5
git push origin --force HEAD
Bash

If you want to remove a specific commit by it commit id

git reset --hard <sha1-commit-id>
git push --forced HEAD
Bash

Where < sha1-commit-d > is the commit id, that you can git by git log


Pull commit

To update your current repo with the latest update from the remote repo, you can use:

git pull
Bash

and if it was already forced push, you can pull it by

git pull --rebase
Bash
Rating
0 0

There are no comments for now.

to be the first to leave a comment.