✏️
rjnotes
  • Home
  • Books To Read in 2023
  • Mac & Ubuntu Commands - v2
  • DevOps Tasks
  • AWS Commands
  • AWS IAM Policies
  • Autoscaling Automation
  • Shell Commands - Unix
  • RJTools
  • Github
  • VAP
  • virtualenv
  • Alembic Commands
  • Aerospike commands
  • AWS Lambda Commands
  • AWS Glue Commands
  • AWS IAM Policies
  • Azure Commands
  • Cassandra Commands
  • Clickhouse Commands
  • Conda Commands
  • Docker Commands
  • IV Assignments
  • AWS Pricing
  • LangChain Commands
  • Python templates
  • PyLint
  • Pandas Commands
  • CICD
  • GitBook - How to publish
  • HTTPS Fix
  • Video Fix
  • Sublime
  • YT Videos
  • Template
  • GenAI Cards
  • Assignment Validator
  • Auth
  • Decision Maker Persona
  • Session Time
  • New Language Learning
  • Finnish Learning
  • Paste Image Extension
  • Director vs Head vs VP
Powered by GitBook
On this page

Was this helpful?

Github

Copy from Gitlab to Github

git@gitlab.com:GladsonWorkspace/analytics/localstack-examples.git
cd localstack-examples
git remote add github git@github.com:rajasgs/localstack-examples.git
git push --mirror github


2

I want to change my master branch to main branch

Changing the default branch name from "master" to "main" in Git can be significant for adopting more inclusive terminology. Here’s how you can do this both locally and on remote repositories such as GitHub, GitLab, or Bitbucket.

Locally Changing the Branch Name

  1. Rename the Branch Locally Open your terminal and navigate to your Git repository. Use the following command to rename the branch:

    git branch -m master main

    This command changes the branch name from master to main.

  2. Push the New Branch to Remote Push the newly named branch to your remote repository:

    git push -u origin main

    This command pushes the main branch to your remote repository (origin) and sets it to track the remote branch.

Remotely Changing the Default Branch

Changing the branch name locally is only part of the process. You also need to update the default branch on your remote repository.

GitHub

  1. Go to your repository on GitHub.

  2. Click on "Settings."

  3. Navigate to "Branches" on the left sidebar.

  4. In the "Default branch" section, click the switch button next to the current default branch.

  5. Select main from the dropdown list.

  6. Confirm the change if necessary.

GitLab

  1. Go to your project in GitLab.

  2. Click on "Repository" and then "Branches."

  3. Click on the "Default branch" button.

  4. Change the default branch to main.

  5. Save the changes.

Bitbucket

  1. Navigate to your repository in Bitbucket.

  2. Click on "Repository settings."

  3. Under "Repository details," find the "Main branch" and select main.

  4. Save your changes.

Clean Up

After changing the default branch, you might want to remove the old master branch from the remote:

git push origin --delete master

This command deletes the master branch from the remote repository.

Update Local Clones

If you or others have local clones of the repository, you should switch to the new main branch in those clones:

git checkout main

Make sure to update the local configurations and reset the upstream tracking branch:

git branch -u origin/main

Summary

Changing the branch name from master to main involves renaming the branch both locally and remotely, then setting the new branch as the default in your Git hosting service. This change is part of a broader effort within the tech community to adopt more inclusive language. Always ensure to communicate these changes with your team or collaborators to avoid confusion and workflow interruptions.


when I do git push it is trying to push it to upstream. I need to change it to only origin

It sounds like the default remote for your current branch has been set to upstream instead of origin. You can change this default remote setting using the git command.

Here's how you can change the default remote (the "upstream" in Git terminology, not to be confused with a remote named "upstream") for your current branch to origin:

  1. Check Current Upstream: First, verify the current upstream (default remote) for your branch with:

    git branch -vv

    This command shows you the upstream configured for each branch.

  2. Change the Upstream Remote: If the current branch is set to push to upstream, change it to origin using:

    git branch --set-upstream-to=origin/<branch>

    Replace <branch> with your current branch name.

  3. Push to Origin: After setting the upstream to origin, you can push using:

    git push

    Now, it should push to origin by default for your current branch.

If you want to push just once to origin without changing the default setting, you can also explicitly specify the remote when pushing:

git push origin <branch>

Make sure to replace <branch> with the name of your branch. This command will push your branch to the origin remote just for this operation, without changing the default remote setting.








PreviousRJToolsNextVAP

Last updated 1 year ago

Was this helpful?