Skip to main content
The 2024 Developer Survey results are live! See the results
I hope it's okay to change it to that, for people who just copy the line as-is, this message would make sense in most cases :)
Source Link
sashoalm
  • 78.1k
  • 129
  • 459
  • 811
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1

To do the above in a single step:

git reset $(git commit-tree HEAD^{tree} -m "commit"Initial message"commit.")
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1

To do the above in a single step:

git reset $(git commit-tree HEAD^{tree} -m "commit message")
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1

To do the above in a single step:

git reset $(git commit-tree HEAD^{tree} -m "Initial commit.")
added 110 characters in body
Source Link
Asclepius
  • 61.6k
  • 18
  • 180
  • 153
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1

To do the above in a single step:

git reset $(git commit-tree HEAD^{tree} -m "commit message")
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1

To do the above in a single step:

git reset $(git commit-tree HEAD^{tree} -m "commit message")
deleted 1 character in body
Source Link
Asclepius
  • 61.6k
  • 18
  • 180
  • 153
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output it'sits name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output it's name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1
echo "message" | git commit-tree HEAD^{tree}

This will create an orphaned commit with the tree of HEAD, and output its name (SHA-1) on stdout. Then just reset your branch there.

git reset SHA-1
Fixed spelling.
Source Link
user456814
user456814
Loading
added 23 characters in body
Source Link
sanmai
  • 30.3k
  • 12
  • 69
  • 76
Loading
added 10 characters in body
Source Link
CharlesB
  • 89.2k
  • 29
  • 197
  • 223
Loading
Source Link
kusma
  • 6.6k
  • 2
  • 24
  • 26
Loading