Skip to content

Instantly share code, notes, and snippets.

@tangoabcdelta
Created July 31, 2023 12:24
Show Gist options
  • Save tangoabcdelta/0da07c875427ed2c9054bd600aafbd81 to your computer and use it in GitHub Desktop.
Save tangoabcdelta/0da07c875427ed2c9054bd600aafbd81 to your computer and use it in GitHub Desktop.
git push origin eval(/the current branch i am on/)
  • Retrieves the name of the currently checked-out branch: git rev-parse --abbrev-ref HEAD
  • The HEAD keyword refers to the currently active commit
  • The param --abbrev-ref ensures that only the branch name (without the "refs/heads/" prefix) is returned.
  • Use the $(...) syntax to execute shell commands within the command line. $(...) is called command substitution in Bash.
  • This allows the output of the git rev-parse command to be used as an argument to git push origin.
  • Push the current branch to the remote named "origin":
git push origin $(git rev-parse --abbrev-ref HEAD)
  • The current branch will be pushed to the remote repository named "origin."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment