Skip to content

Commit

Permalink
added note about usethis::use_git_config(init.defaultBranch = "main")…
Browse files Browse the repository at this point in the history
… to update git config
  • Loading branch information
samanthacsik committed Sep 28, 2024
1 parent 40db381 commit 0baed0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,10 @@ <h3 class="anchored" data-anchor-id="steps"><strong>Steps:</strong></h3>
<li><p>Open RStudio’s Terminal window (next to the Console) and run either <code>git branch</code> (this prints all local branches and highlights the one that you’re currently on) or <code>git status</code> (the first printed line should say <code>On branch &lt;branch_name&gt;</code>).</p></li>
<li><p>Click on the <strong>Git</strong> tab in the top right pane of RStudio. Next to the <img src="media/branch.png" class="img-fluid" style="display: inline-block; margin: 0; position: relative; top: 0px; width:20px;height:18px;" alt="A white diamond with two purple squares, one directly above and one directly to the right, connected to the diamond by a line."> symbol, you should see a dropdown menu that displays the name of your current branch.</p></li>
</ol></li>
<li><p><strong>If your current branch is named <code>master</code>, update the name to <code>main</code>.</strong> <em>(If your branch is named </em><code>main</code><em>, you’re good to go! You can skip this step.)</em> In the console, run <code>usethis::git_default_branch_rename(from = "master", to = "main")</code> to update your default branch name. Confirm that it updated by running <code>git status</code> again in your Terminal – the first printed line should now read, <code>On branch main</code>. <!-- and b. on your remote by refreshing your GitHub repo (in your web browser) -- you should see the updated default branch name at the top of your repo --></p></li>
<li><p><strong>If your current branch is named <code>master</code>, update the name to <code>main</code>.</strong> <em>(If your branch is named </em><code>main</code><em>, you’re good to go! You can skip this step.)</em> In the console, run <code>usethis::git_default_branch_rename(from = "master", to = "main")</code> to update your default branch name. Confirm that it updated by running <code>git status</code> again in your Terminal – the first printed line should now read, <code>On branch main</code>. <!-- and b. on your remote by refreshing your GitHub repo (in your web browser) -- you should see the updated default branch name at the top of your repo --></p>
<ul>
<li>The above function only updates your default branch name for <em>this</em> respository. <strong>You’ll also want to update your git config file so that the default branch name of any future local git repository is automatically named <code>main</code>.</strong> Run <code>usethis::use_git_config(init.defaultBranch = "main")</code> to do so.</li>
</ul></li>
</ol>
<div class="callout callout-style-default callout-note callout-titled">
<div class="callout-header d-flex align-content-center" data-bs-toggle="collapse" data-bs-target=".callout-13-contents" aria-controls="callout-13" aria-expanded="false" aria-label="Toggle callout">
Expand Down
1 change: 1 addition & 0 deletions sections/5-RStudio.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ knitr::include_graphics("media/git-repo-ex.png")

6. **If your current branch is named `master`, update the name to `main`.** *(If your branch is named *`main`*, you're good to go! You can skip this step.)* In the console, run `usethis::git_default_branch_rename(from = "master", to = "main")` to update your default branch name. Confirm that it updated by running `git status` again in your Terminal -- the first printed line should now read, `On branch main`.
<!-- and b. on your remote by refreshing your GitHub repo (in your web browser) -- you should see the updated default branch name at the top of your repo -->
- The above function only updates your default branch name for *this* respository. **You'll also want to update your git config file so that the default branch name of any future local git repository is automatically named `main`.** Run `usethis::use_git_config(init.defaultBranch = "main")` to do so.

{{< include /sections/NOTE-master-main.qmd >}}

Expand Down

0 comments on commit 0baed0b

Please sign in to comment.