Skip to content

Commit

Permalink
add master main renaming instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
ngotelli committed Jan 18, 2024
1 parent 3995910 commit 6a52dd5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
38 changes: 35 additions & 3 deletions Lectures/GitHub.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,41 @@ output:
* Note the address: https://UserName.github.io/RepoName/
* Example: https://ngotelli.github.io/Trial/

## Optional: rename "master" branch to "main" branch

These instructions are modified from [Scott Hanselman's blog]( https://www.hanselman.com/blog/easily-rename-your-git-default-branch-from-master-to-main)

* from the github General page, find the box to change "master" to "main"


* Now go to each of your local clones of this repository and run the following from the terminal prompt (`$` is the prompt before the command)

```
$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
# git config --global init.defaultBranch main
```
These commands need to be issued only once for each local copy of the repository. These commands do the following:

```
1. Go to the master branch
2. Rename master to main locally
3. Get the latest commits from the server
4. Remove the link to origin/master
5. Add a link to origin/main
6. Update the default branch to be origin/main
7. Change git configuration to recognize main (may only need to be done once)
```



# Basic workflow for git from the terminal


## Check things out before starting your work
* `git status` (make sure your local repo is not ahead of the remote)
* `git pull` (just in case there was a change made from another location)
Expand All @@ -122,12 +154,12 @@ output:
* `git status`
* `git pull`



# Summary of workflow
- check `status` of the local repo (uncommitted changes? local commits ahead of remote?)
- `pull` any changes from the repo (incorporating changes pushed by others)
- do some work (edit, create, delete files)
- `add` changes (local)
- `commit` changes (local)
- `push` changes (from local repo to GitHub)
- `push` changes (from local repo to GitHub)

[1]: From the blog post https://www.hanselman.com/blog/easily-rename-your-git-default-branch-from-master-to-main
28 changes: 28 additions & 0 deletions Lectures/GitHub.html
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,34 @@ <h2>Host the “index” webpage</h2>
<li>Example: <a href="https://ngotelli.github.io/Trial/" class="uri">https://ngotelli.github.io/Trial/</a></li>
</ul>
</div>
<div id="optional-rename-master-branch-to-main-branch" class="section level2">
<h2>Optional: rename “master” branch to “main” branch</h2>
<p>These instructions are modified from <a href="https://www.hanselman.com/blog/easily-rename-your-git-default-branch-from-master-to-main">Scott
Hanselman’s blog</a></p>
<ul>
<li><p>from the github General page, find the box to change “master” to
“main”</p></li>
<li><p>Now go to each of your local clones of this repository and run
the following from the terminal prompt (<code>$</code> is the prompt
before the command)</p></li>
</ul>
<pre><code>$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
# git config --global init.defaultBranch main</code></pre>
<p>These commands need to be issued only once for each local copy of the
repository. These commands do the following:</p>
<pre><code>1. Go to the master branch
2. Rename master to main locally
3. Get the latest commits from the server
4. Remove the link to origin/master
5. Add a link to origin/main
6. Update the default branch to be origin/main
7. Change git configuration to recognize main (may only need to be done once)</code></pre>
</div>
</div>
<div id="basic-workflow-for-git-from-the-terminal" class="section level1">
<h1>Basic workflow for git from the terminal</h1>
Expand Down

0 comments on commit 6a52dd5

Please sign in to comment.