Skip to content

Commit

Permalink
Add branch names to "git push -u remote" commands
Browse files Browse the repository at this point in the history
The default setting for `push.default` requires the user to configure an
upstream branch with the same name as the local branch in order for
`git push -u remote` to push the local branch upstream.
  • Loading branch information
robmoss committed Feb 28, 2024
1 parent 9962b29 commit e9b8dd8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/collaborating/sharing-a-branch.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Remember that you can merge commits from their branch into your own branches at
2. Push this branch to your remote repository:

```sh
git push -u origin
git push -u origin collab/jamie
```

3. Your collaborator can then make a local copy of this branch:
Expand Down
2 changes: 1 addition & 1 deletion docs/using-git/how-to-use-branches.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ git checkout -b my-new-branch my-other-branch # From an existing branch
You can then create a corresponding **upstream branch** in your remote repository (in this example, called "origin") by running:

```sh
git push -u origin
git push -u origin my-new-branch
```

## Working on a remote branch
Expand Down
11 changes: 9 additions & 2 deletions docs/using-git/pushing-and-pulling-commits.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ This requires that you have **created at least one commit** in your local reposi
Once you have at least one commit in your local repository, you can create a corresponding **upstream branch** in the remote repository with the following command:

```sh
git push -u origin
git push -u origin <branch-name>
```

The default branch will probably be called `"main"` or `"master"`, depending on your [Git settings](first-time-git-setup.md).
You can identify the branch name by running:

```sh
git branch
```

!!! note
Expand All @@ -50,7 +57,7 @@ and pull commits by running:
git pull
```

without having to specify the remote repository.
without having to specify the remote repository or branch name.

## Forcing updates to a remote repository

Expand Down

0 comments on commit e9b8dd8

Please sign in to comment.