Git: How can I change server commit?

I already pushed some commits on my git server on EC2 and not on github.

How do I change these commits on a git server?

An operation like deleting a commit, for example, reloading, changing a commit message

Is it possible?

Many thanks.

+8
git
source share
2 answers

You can do almost anything with a push. Change the local tree to what you want and git push -f and it will replace the tree on the server with what you have locally. It is worth noting that this will cause problems with any other repositories that pulled out the tree you just replaced.

+9
source share

If you want to change the history of remote branches destructively (e.g. rebase / amend ), make your changes locally and then do git push --force . Sometimes this does not work (repository administrators can disable this feature); in this case, you can try to delete the remote branch using git push origin :my_branch and then click it again with git push origin my_branch . Otherwise, you can use git revert , which is recommended if you are working in a team (the rule of thumb is that the published story should not be changed).

Here is an example (using this Github repository ):

 $ touch SOMETHING $ emacs SOMETHING $ git add SOMETHING $ git ci -m SOMETHING [master d14aaa0] SOMETHING 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 SOMETHING $ git push Counting objects: 8, done. Compressing objects: 100% (5/5), done. Writing objects: 100% (6/6), 611 bytes, done. Total 6 (delta 3), reused 0 (delta 0) To git@github.com:23Skidoo/ghc-parmake.git 53f836a..d14aaa0 master -> master $ git reset --hard "HEAD~" HEAD is now at 7b2dc96 TODO update. $ git push --force Total 0 (delta 0), reused 0 (delta 0) To git@github.com:23Skidoo/ghc-parmake.git + d14aaa0...7b2dc96 master -> master (forced update) 

Looking at the commit history , you can see that commit d14aaa0 is missing.

+7
source share

All Articles