Turn some existing git snippets into stories

This commit is contained in:
Angelos Chalaris
2023-05-21 16:56:48 +03:00
parent 2f33473c54
commit af67750a5f
2 changed files with 21 additions and 24 deletions

View File

@ -1,23 +1,20 @@
---
title: Automate upstream branch creation
type: snippet
title: "Tip: Automate upstream branch creation"
shortTitle: Automate upstream branch creation
type: tip
language: git
tags: [configuration,repository]
author: chalarangelo
cover: messy-computer
dateModified: 2022-10-19T05:00:00-04:00
excerpt: Effortlessly create upstream branches on push by enabling a simple git config setting.
dateModified: 2023-05-21T05:00:00-04:00
---
Configures the repository to automatically create upstream branches on push.
- Use `git config --add --bool` to enable automatic upstream branch creation on push.
- You can use the `--global` flag to enable this setting globally.
Manually creating upstream branches on push can be a tedious task. Luckily, Git provides a way to automate this process. You can use `git config` to enable automatic upstream branch creation on push:
```shell
git config [--global] --add --bool
```
```shell
git config --global --add --bool
git config [--global] --add --bool push.autoSetupRemote true
# `git push` will automatically create new branches, if they don't exist
```
Using `push.autoSetupRemote` will automatically create a new branch on the remote repository, if it doesn't exist. Workflows that benefit most from this setup are ones where local branches are expected to have the same name as their remote counterparts. You can use the `--global` flag to enable this setting globally on your machine.