2016-01-26 12 views
5

Dopo aver eseguito un rebase interattivo in git, desidero avere un messaggio di commit che inizi con il carattere # (cancelletto o cancelletto), ma le righe che iniziano con # vengono considerate come commenti e ignorate.Escape # carattere nel messaggio di commit rebase interattivo

Esiste un modo per evitare il carattere # per far sì che il mio messaggio di commit inizi effettivamente con #?

Maggiori dettagli

sto eseguendo un rebase interattivo utilizzando:

git rebase -i HEAD~4 

Poi, nel l'editor che sto facendo tutto ciò che è necessario, ad esempio:

pick b010299 #91691 Add test for logging in with valid credentials 
reword 5e9159d 91691 Implement log-in feature 
pick 2735aa3 #91691 Re-factor logic 
pick 14bd500 #91691 Tidy up 'using' declarations 

# Rebase 60d6e3f..14bd500 onto 60d6e3f 
# 
# Commands: 
# p, pick = use commit 
# r, reword = use commit, but edit the commit message 
# e, edit = use commit, but stop for amending 
# s, squash = use commit, but meld into previous commit 
# f, fixup = like "squash", but discard this commit's log message 
# x, exec = run command (the rest of the line) using shell 
# 
# These lines can be re-ordered; they are executed from top to bottom. 
# 
# If you remove a line here THAT COMMIT WILL BE LOST. 
# 
# However, if you remove everything, the rebase will be aborted. 
# 
# Note that empty commits are commented out 

Poi git carica il messaggio di commit nel mio editor di testo per il commit che voglio riformulare, ma voglio salvare il mio messaggio di commit con un # all'inizio:

#91691 Implement log-in feature 

# Please enter the commit message for your changes. Lines starting 
# with '#' will be ignored, and an empty message aborts the commit. 
# rebase in progress; onto 60d6e3f 
# You are currently editing a commit while rebasing branch 'master' on '60d6e3f'. 
# 
# Changes to be committed: 
# modified: My.Website.LogInController.cs 

Ma ciò significa che il mio messaggio di commit verrà ignorato. Come faccio a realizzare il messaggio di commit #91691 Implement log-in feature?

risposta

9

Se si salva sei messaggio di commit con il # così in effetti il ​​vostro messaggio di commit è vuoto (si potrebbe anche eliminare tutto nel messaggio), git vi mostrerà cosa fare:

Aborting commit due to empty commit message. 
Could not amend commit after successfully picking 5e9159d9ce3a5c3c87a4fb7932fda4e53c7891db... 91691 Implement log-in feature 
This is most likely due to an empty commit message, or the pre-commit hook 
failed. If the pre-commit hook failed, you may need to resolve the issue before 
you are able to reword the commit. 
You can amend the commit now, with 

     git commit --amend 

Once you are satisfied with your changes, run 

     git rebase --continue 

Così , basta modificare il messaggio:

git commit --amend -m "#91691 Implement log-in feature" 

e continuare il rebase:

git rebase --continue 
+0

e se la commetto s molto grande e multi-linea, come si può aggiungere l'hashmark all'inizio della riga? – Mohammed

+0

Basta inserire le interruzioni di linea prima di chiudere i doppi apici. Git è contento dei messaggi di commit multilinea e lunghi. –

Problemi correlati