fertsociety.blogg.se

Git commands
Git commands








Switch-default = !git switch $(git default-branch) You can also use subshells: Switch to the default branch. & git rev-parse -abbrev-ref origin/HEAD \ Git remote set-head origin -a > /dev/null \ The first command asks the remote if the default branch was changed.

git commands

You may want to break your command into multiple lines:ĭo so by wrapping your command into quotes and prepending every new line with a backslash. Piping output into other commands is available out of the box.Įxecuting multiple commands is just a & away. git cat 2eea778 package.json to get the file contents of a file at a certain revision: The following example will let you do e.g. If you use an exclamation mark before your command, you can run any Shell command you want, even with parameters. Let's instead talk about actual custom commands: With Parameters

git commands

Nowadays, with the Git plugin of oh-my-zsh, I don't feel there is a great need for such shortcuts. how you can abbreviate git checkout to git co by running git config -global checkout.Īs an alternative to the CLI command, you can add this section to your ~/.gitconfig file: Many articles about Git aliases explain only the shortcut side. With this article, I want to introduce what I learned about Git aliases – and in the process, you get all the aliases I defined for my cleanup 😉 Defining Shortcuts These are Git commands you can define yourself, either via CLI or in the Gitconfig file. I first considered performing it through the GitHub API, but then I decided to try doing it via Git itself.Īfter I had begun dabbling with a few wrapper scripts, I suddenly remembered something which massively simplified my strategy: Recently I wanted to do a bulk cleanup on some GitHub repositories I am responsible for, like deleting old branches that have already been merged into the default branches.










Git commands