Git Commands – How to remove and fix git connection

Posted on: July 27th, 2024
By: Tadeo Martinez

To fully remove all GIT association from a folder, run the following command:

rm -rf .git
git remote remove origin

git remote add origin git_url

git remote set-url origin git_url

To fix:
To github.com:git_url
 ! [rejected]          main -> main (fetch first)
error: failed to push some refs to 'github.com:git_url'

git fetch origin

git merge origin/main

Now start to push:
git add .
git commit -m "test"
git push -u origin main

Abort changes

Do this if someone fixed the conflicts and you had already started but want to download the latest changes.

git merge --abort

Add Origin

git remote add origin git@github.com:elemusma/supabase-tutorial.git

Add branch and switch to it

git checkout -b branch_name

Check current branch

Checks current git connection

git branch
git checkout main

How to change and create new GIT Connection

git checkout -b new-branch-connection
git branch
git add .
git commit -m "Your commit message"
git push -u origin new-branch-connection

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *