Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active October 6, 2021 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Beyarz/80e6b6c6de302b08b190bc3a3a9ff49f to your computer and use it in GitHub Desktop.
Save Beyarz/80e6b6c6de302b08b190bc3a3a9ff49f to your computer and use it in GitHub Desktop.
git remote

Notes


Get remotes

git remote -v

Change git remote url

git remote set-url <remote_name> <remote_url>

git remote set-url origin https://git-repo/new-repository.git

Undo last commit

git reset --soft head~1

Add origin

git remote add origin https://host.com/name/project.git

Push

git push -u origin main

Remove origin

git remote remove origin

Add single origin

git remote set-url --add origin https://host.com/name/project.git

Delete single origin

git remote set-url --delete origin https://host.com/name/project.git

Push an existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@ssh.gitgud.io:YOU/PROJECT.git
git push -u origin --all
git push -u origin --tags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment