Published on

Some useful git commands

Authors
  • avatar
    Name
    Loc Truong
    Twitter

To obtain only the remote URL

git config --get remote.origin.url

Set remote access via a token

git remote set-url origin https://token@github.com/username/repository.git

Create the branch on your local machine and switch in this branch

git checkout -b [name_of_your_new_branch]

Push the branch on github

git push origin [name_of_your_new_branch]

Take it back

git reset HEAD~1   # Undo the last commit
rm -rf myfolder    # Delete the folder
git add .          # Stage the changes
git commit -m "Removed myfolder"  # Commit the changes