GitHub Topics (7)Tap to view
    GitHub·Version Control·Topic 2 of 7

    GitHub Repositories & Remotes

    Manage repositories, name virtual branches, set remote tracking, and untrack sensitive files.

    1. Repositories Management & Remote Tracking

    1. git remote -v

      What it doesDisplays the names and addresses of registered remote repositories (fetch and push)

      When to use itto check the remote link before uploading or fetching

      Examplegit remote -v

    2. git branch -M main

      What it doesRenames the current branch to main as the default GitHub-compatible branch name

      When to use itWhen initializing a new repository and converting master to main

      Examplegit branch -M main

    3. git push -u origin main

      What it doesUploads the local branch to the remote repository and sets upstream tracking

      When to use itOn the first master branch push to GitHub

      Examplegit push -u origin main

    4. git rm --cached <file>

      What it doesRemoves the file from the Staging index but keeps it on the local storage disk

      When to use itWhen you accidentally add a sensitive file and want to include it in .gitignore without deleting it

      Examplegit rm --cached .env

    5. gh repo view

      What it doesDisplays a summary of the current repository from the command line (description, stars, and default branch)

      When to use itTo quickly view repository details without opening the browser

      Examplegh repo view

    6. gh repo view --web

      What it doesOpens the current repository page directly in the default web browser

      When to use itto jump directly to the GitHub interface in the browser

      Examplegh repo view --web

    Offline · Reading cached copy