DEV Community

Cover image for Git Commands
Akash Yadav
Akash Yadav

Posted on

1

Git Commands

Git Commands: Set Remote and Related Operations

  1. Setting Up a Remote Repository:

    • git remote add origin <remote_repository_url>: Sets up a remote repository with the specified URL as the origin.
  2. Listing Remote Repositories:

    • git remote -v: Lists all remote repositories along with their URLs.
  3. Renaming a Remote Repository:

    • git remote rename <old_name> <new_name>: Renames a remote repository.
  4. Changing the URL of a Remote Repository:

    • git remote set-url origin <new_repository_url>: Changes the URL of the remote repository named 'origin'.
  5. Removing a Remote Repository:

    • git remote remove <remote_name>: Removes the remote repository specified by the name.
  6. Pushing Changes to a Remote Repository:

    • git push <remote_name> <branch_name>: Pushes changes from the local branch to the remote repository.
  7. Pushing Changes to a New Remote Repository:

    • git push -u origin <branch_name>: Pushes changes to a new remote repository and sets it as the default upstream.
  8. Fetching Changes from a Remote Repository:

    • git fetch <remote_name>: Fetches changes from the remote repository without merging them into the local branch.
  9. Pulling Changes from a Remote Repository:

    • git pull <remote_name> <branch_name>: Fetches changes from the remote repository and merges them into the current branch.
  10. Cloning a Remote Repository:

    • git clone <remote_repository_url>: Clones a remote repository to the local machine.
  11. Viewing Remote Details:

    • git remote show <remote_name>: Displays detailed information about the specified remote repository.
  12. Verifying Remote Connectivity:

    • git remote -v: Verifies the connectivity with the remote repository.
  13. Creating a New Branch on the Remote Repository:

    • git push <remote_name> <local_branch_name>:<remote_branch_name>: Creates a new branch on the remote repository.
  14. Deleting a Branch on the Remote Repository:

    • git push <remote_name> --delete <branch_name>: Deletes the specified branch from the remote repository.
  15. Pushing Tags to the Remote Repository:

    • git push <remote_name> --tags: Pushes tags to the remote repository.
  16. Pushing Changes with Force to Remote Repository:

    • git push --force <remote_name> <branch_name>: Forces the push of local changes to the remote repository, potentially overwriting changes.

These commands allow you to manage remote repositories in Git, including setting up, renaming, removing, and interacting with remote repositories for collaboration and version control. Use them to effectively work with remote repositories in your Git projects.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay