3 Common Processes
3.1 Remove Local Branch After Merge
After merging a task branch into main on GitHub, you will delete it. This branch will no longer be available on the GitHub browser but it is still on your local machine.
After merging and deleting the merged branch:
git fetch origin- pull all changes to repo
git checkout main- check out main (or develop), as long as you aren’t on the branch that is going to be removed
git remote prune origin- remove all the remote branches that have been deleted
git branch -d BRANCH- delete branch locally, may need to use-Dto force delete
3.2 Ignore any differnces on clone and resent to version on GitHub
git fetch origin BRANCH
This will get the most recent versions from GitHub
git reset --hard origin/BRANCH
This will change all files in your clone repository to match the most up-to-date version from GitHub
This should be done rarely because any changes you have worked on will not be saved.
3.3 Rename Default Branch from Master to Main
On GitHub’s website click on # branches icon at the top left of the code on the home page of a repository. You should see a window that specifies all the current branches as well as the default branch. Click on the edit icon (pencil on far right) to rename a branch.
After renaming the branch on the web interface, then go to your local clone, open bash and type in the following:
git branch -m master main
git fetch origin
git branch -u origin/main main
git remote set-head origin -a3.4 Cache GitHub Credentials (Windows)
Old way, view in Wayback Machine
New way, using GitHub CLI or Git Credential Manager
- After installing git on a new machine, I cloned a test repository (via an RStudio .Rproj) made a small text edit and committed the change. When I tried to push the commit to GitHub the following window popped-up asking me to sign in. I selected Sign in with your browser.

- After selecting Sign in with your browser, a window popped up in my default browser where I signed in to my GitHub account. The next screen asked to authorize the credential manager, which I did by selecting Authorize GitCredentialManager.

- After selecting Authorize GitCredentialManger the following screen appeared stating that authentication succeeded. After this, I am able to push/pull from my machine to GitHub.

3.5 Git Bash Terminal in R Studio
Tools > Global Options > Terminal > New Terminals open with: Git Bash
3.6 Update Remote Link
Remote link will need to be updated if the repo changes names or ownership.
- Go into repository on GitHub, click the green “Code” button and copy the HTTPS url
- Got to the repository folder on your machine, right click and select “Git Bash Here”
-
Change the remote link with the following:
git remote set-url origin NEW_URL -
Check to see if the link has been updated using:
The URL should now be the updated version.git config --get remote.origin.url