Skip to content

Latest commit

 

History

History
91 lines (73 loc) · 2 KB

GitHub - Commands.md

File metadata and controls

91 lines (73 loc) · 2 KB

Git commands

Introduction

GitHub is a platform for storing and sharing code. This guide covers basic GitHub commands to help you manage your code, track changes, and work with others on projects.


Git global auth/credentials

git config --global user.email "villanuevajoshua27@gmail.com"
git config --global user.name "koykoy027"

Git remote auth/credentials

git config user.email "villanuevajoshua27@gmail.com"
git config user.name "koykoy027"

Generate SSH

ssh-keygen -t rsa -b 4096 -C "villanuevajoshua27@gmail.com"

How to Login via Personal access token

git credential-store --file ~/.git-credentials store <<EOF
protocol=https
host=github.com
username=koykoy027
password=`your_personal_access_token`
EOF
git config --global credential.helper store

Verify Authentication

To check the global Git user name:

git config --global user.name

To check the global Git user email:

git config --global user.email

To check the list of all configurations, including user-related configurations:

git config --global --list

If you are looking to see which user is currently authenticated for a specific repository, you can use the following command:

git config user.name

If you want to see information about the currently logged-in user on your Ubuntu system, you can use the whoami command:

whoami

Update git

update default branch, from master to main

git branch -m master main
git fetch origin
git branch -u main main
git remote set-head origin -a

If the remote URL or branch name is incorrect, update it using the following commands

git remote set-url origin <new-remote-url>
git branch --set-upstream-to=origin/<correct-branch-name> main

How to ignore all files and folders

*
!*gitignore

How to revert commit with SHA

git revert -m 1 <SHA>