Per spostare solo la testa (come richiesto - questa operazione non aggiorna l'indice o albero di lavoro), l'uso:
git reset --soft $(git child)
Avrete bisogno di utilizzare la configurazione di seguito elencati.
Spiegazione
Sulla base di @Michael's answer, ho inciso l'alias child
nel mio .gitconfig
.
Funziona come previsto nel caso predefinito ed è anche versatile.
# Get the child commit of the current commit.
# Use $1 instead of 'HEAD' if given. Use $2 instead of curent branch if given.
child = "!bash -c 'git log --format=%H --reverse --ancestry-path ${1:-HEAD}..${2:\"$(git rev-parse --abbrev-ref HEAD)\"} | head -1' -"
Il valore predefinito dando al bambino di HEAD (argomento meno che un altro commit-ish è dato) seguendo la discendenza un passo verso la punta del ramo corrente (meno che un altro commit-ish è dato come secondo argomento) .
Utilizzare %h
anziché %H
se si desidera il modulo di hash breve.
Con una testa staccata, non c'è ramo, ma ricevendo il primo figlio può ancora essere raggiunto con questo alias:
# For the current (or specified) commit-ish, get the all children, print the first child
children = "!bash -c 'c=${1:-HEAD}; set -- $(git rev-list --all --not \"$c\"^@ --children | grep $(git rev-parse \"$c\")); shift; echo $1' -"
Modificare il $1
per $*
per stampare tutti i bambini
fonte
2016-09-18 14:14:47
puoi anche consultare i script/comando ['git children-of'] (http://stackoverflow.com/a/20141722/6309)! – VonC
C'è una buona soluzione su http://stackoverflow.com/questions/2263674/how-do-i-find-the-next-commit-in-git –