Table of contents
- Logout- Remove your user settings
- Removes the file or directory from staging area without deleting it from your local filesystem
- Setting up global config for 1st time
- Initialize Repository
- Determine current branch
- Switch Between Branches
- Rename Branch
- Create a New Branch
- Delete the Feature Branch
- Add Your Content
- Status of current state of the working directory & staging area
- Commit Your Changes
- Add URL
- Check Current URL
- Update remote repo URL if, it has changed & can also add PAT token -> login
- Push to Remote Repository
- Version and Commit Changes in Repository
- Merge Options
- Types of authentication to push changes to remote repo
Logout- Remove your user settings
# Unset global configurations git config --global --unset user.name git config --global --unset user.email git config --global --unset credential.helper # Clear cached credentials (if using cache helper) git credential-cache exit
Removes the file or directory from staging area
without deleting it from your local filesystem
git rm --cached <file or dir to be remove from staging>
Setting up global config for 1st time
git config --global user.email "you@example.com" git config --global user.name "Your Name"
Initialize Repository
git init
Determine current branch
git branch
Switch Between Branches
git checkout main
Rename Branch
# Rename branch name from master to main git branch -m master main
Create a New Branch
git checkout -b blog-post-title
Delete the Feature Branch
git branch -d feature
Add Your Content
git add <file-name>
Status of current state of the working directory & staging area
git status
Commit Your Changes
git commit -m "message"
Add URL
git remote add origin <remote repo address>
Check Current URL
git remote -v
Update remote repo URL if, it has changed
& can also add PAT token -> login
git remote set-url origin <new-url>
Push to Remote Repository
# orgin(default)- remote repo name # main- remote repo branch name git push origin main #upstream reference git push -u origin main
Version and Commit Changes in Repository
git log
Merge Options
Cherry-Pick: Include Specific Changes from One Branch Without Merging All Changes
git cherry-pick
Merge: Merge Commit that Combines the Histories of the Branches
git merge <branch-name>
Rebase: Reapply Commits on Top of Another Base Commit, Resulting in a Linear History
git rebase <branch-name>
Types of authentication to push changes to remote repo
SSH (Secure Shell) Authentication:
Uses public-private key pairs.
Provides secure, password-less access.
URL format:
git@github.com
:username/repository.git
.
HTTPS with Personal Access Token (PAT):
Replaces passwords with tokens generated in the Git platform (e.g., GitHub).
Tokens are used in the URL for authentication.
URL format:
https://username:token@github.com/username/repository.git
.
OAuth (Open Authorization):
Token-based authentication without directly exposing credentials.
Often used with third-party services like GitHub Apps.
GPG (GNU Privacy Guard) Signing:
- Signs commits and tags with GPG keys for authenticity verification.
Kerberos Authentication:
A network authentication protocol commonly used in enterprise settings.
URL format:
https://example.com/repo.git
.
Credential Manager (Windows/Mac/Linux):
- Stores and manages credentials securely using system-specific managers like Windows Credential Manager, macOS Keychain, or
git-credential-libsecret
for Linux.
- Stores and manages credentials securely using system-specific managers like Windows Credential Manager, macOS Keychain, or
Feel free to share and spread the knowledge! ๐๐ Enjoy Learning! ๐