Correggere un commit in git

From RVM Wiki
Revision as of 13:09, 11 January 2012 by Gabriele.vivinetto (talk | contribs) (Created page with "*Se si sbaglia il messaggio di commit e lo si vuole correggere: git commit --amend "My fixed commit message" * Se si vuole aggiungere un file ad un commit già eseguito, o si v…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
  • Se si sbaglia il messaggio di commit e lo si vuole correggere:
git commit --amend "My fixed commit message"
  • Se si vuole aggiungere un file ad un commit già eseguito, o si vogliono inserire dei files modificati
git add mynewfile
git commit --amend "My fixed commit message"

Attenzione, però, che in questo caso si creano problemi per un push. Infatti se si tenta un push, si ottiene un errore. Per poter continuare, fare prima un pull:

git pull

Se non si riesce a fare il pull, controllare .git/config e verificare i branch etc ...

Controllare, e poi fare il push

git push

Riferimenti