Git is a distrubuted version control system / tool, while Github is a web-based hosting service for git repositories.
Local storage --> Staging area --> Github
git status
git add .
git status
git commit -m "initial commit"
git remote set-url origin https://<SSH Key>@github.com/<user>/<repo>
git push origin main
List of Git commands
- Command:
git add file1 file2
- Command:
git add .
- to add everything at once - Command:
git add ./folder
- to add any specific folder - Command:
git add *.py
- to add all files with the given suffix
- Command:
git commit -m "initial commit"
- Command:
git commit -m "Fixed the bug that ..."
git reset HEAD -- <file>
git reset HEAD -- <directoryName>
Your modifications will be kept. When you run git status
the file will once again show up as modified but not yet staged.
git reset <file>
-> That will remove the file from the current index (the "about to be committed" list) without changing anything else.
To unstage all files from the current change set:
git reset
git remote add origin <url>
-> Add the URL for the remote repository where your local repository will be pushedgit remote add origin https://github.com/<user>/<repo>.git
git push origin master
From 2021-08-13, GitHub is no longer accepting account passwords when authenticating Git operations. You need to add a PAT (Personal Access Token) instead, and you can follow the below method to add a PAT on your system.
From your GitHub account, go to Settings → Developer Settings → Personal Access Token → Tokens (classic) → Generate New Token (Give your password) → Fillup the form → click Generate token → Copy the generated Token, it will be something like
ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta
git clone https://<tokenhere>@github.com/<user>/<repo>.git