Show current Git configuration
git config --list --show-origin
Displays all Git configuration values and the source file where each one is defined.
A professional single-page guide for everyday Git usage — from initial setup and authentication to branches, syncing, stashing, diffs, recovery, and best practices.
Configure your Git identity and inspect the settings Git uses on your machine.
git config --list --show-origin
Displays all Git configuration values and the source file where each one is defined.
git config --global --edit
Opens your global Git config file. On Windows it is commonly located at C:\Users\shuva\.gitconfig.
git config --global user.name "Shuvabrata Dey"
Defines the author name that will be attached to your commits.
git config --global user.email "shuvabratadey@gmail.com"
Defines the author email used in your commit history.
git config --global --add safe.directory '*'
Marks all directories as safe for Git operations. Useful in some multi-user or permission-restricted environments.
git config --global credential.helper cache
Temporarily remembers your credentials so you do not need to re-enter them every time.
Do not store your GitHub password using custom Git config keys. Use a Personal Access Token or Git Credential Manager instead.
Start a repository locally, connect it to GitHub, or clone an existing project.
git init
Creates a new local Git repository in the current folder.
git remote add origin <repository-link>
Links your local repository to a remote GitHub repository.
git remote -v
Shows the remote repository URLs used for fetch and push.
git clone https://github.com/shuvabratadey/FPGA-CPU-Design.git
Downloads a copy of the remote repository to your local machine.
GitHub no longer accepts standard account passwords for Git over HTTPS. Use a Personal Access Token instead.
https://github.com/settings/tokens
Generate a Personal Access Token from your GitHub account settings.
git push origin master
When prompted, enter your GitHub username and paste the token where Git asks for the password.
On Windows, using git config --global credential.helper manager-core is usually better than plain credential caching.
These are the commands you will use most often while working on a project.
git status
Shows changed, staged, and untracked files.
git add .
Adds all current changes to the staging area.
git add <file_name>
Stages only the selected file.
git commit -m "Your commit message"
Saves the staged changes in a commit with a descriptive message.
git push origin master
Uploads your local commits to the remote branch.
git push --set-upstream origin master
Pushes the branch and links it to the remote tracking branch.
Many repositories use main instead of master. Use the correct default branch for your project.
Create, switch, list, and delete branches as part of a clean development workflow.
git branch <branch_name>
Creates a new branch without switching to it.
git checkout <branch_name>
Moves your working directory to the selected branch.
git checkout -b <branch_name>
Creates a new branch and switches to it immediately.
git switch <branch_name>
A newer and clearer alternative to git checkout for changing branches.
git push origin <branch_name>
Uploads the selected branch to GitHub.
git branch -d <branch_name>
Deletes a merged local branch.
git branch -D <branch_name>
Deletes a branch even if it has not been merged.
git push origin --delete <branch_name>
Removes the branch from the remote repository.
Keep your local repository updated and integrate changes from GitHub correctly.
git pull origin master
Fetches and merges the latest changes from the remote branch.
git pull --set-upstream origin master
Associates your current branch with the remote tracking branch while pulling.
git fetch
Downloads changes from the remote repository without merging them.
git fetch --all
Retrieves updates from all configured remotes.
git merge origin/master
Merges the fetched remote branch into your current branch.
git pull --rebase origin master
Reapplies your local commits on top of the updated remote history.
Temporarily save unfinished work so you can switch branches or pull updates safely.
git stash
Stores your uncommitted changes temporarily.
git stash pop
Reapplies the most recent stash and removes it from the stash list.
git stash apply
Reapplies a stash but keeps it available for reuse.
git stash list
Shows every saved stash entry.
git stash drop stash@{0}
Deletes the selected stash entry.
git stash clear
Removes all saved stash entries permanently.
Inspect commit history to understand the timeline of changes in your repository.
git log
Displays detailed commit history.
git log --oneline
Shows a condensed list of commits.
git log --all --decorate --graph --oneline
Displays a branch graph with labels for commits, branches, and tags.
git log -1
Shows the details of the most recent commit.
git blame <file_name>
Shows who last changed each line in a file.
Compare working files, staged changes, branches, or specific commits.
git diff
Displays differences that are not yet staged.
git diff <file_path/file_name>
Displays changes for a particular file only.
git diff --staged
Shows changes already added to the staging area.
git diff <commit1> <commit2>
Displays the difference between any two commits.
git diff master..feature-branch
Shows what differs between two branches.
Move between commits and branches, or discard unwanted local changes.
git checkout <commit_id>
Moves your working directory to a selected commit.
git checkout -
Returns to the last checked-out branch.
git restore <file_name>
Discards changes in a file and restores the last committed version.
git restore --staged <file_name>
Removes a file from the staging area while keeping the file changes.
Undo commits or move your branch pointer depending on whether you want to rewrite history or preserve it.
git reset --soft HEAD~1
Removes the last commit but keeps the changes staged.
git reset HEAD~1
Removes the last commit and unstages the changes.
git reset --hard HEAD~1
Deletes the last commit and permanently removes the changes from your working directory.
git reset --hard <commit_id>
Moves the current branch to a particular commit.
git revert <commit_id>
Creates a new commit that reverses the selected commit without rewriting project history.
Use git reset --hard carefully. It permanently removes uncommitted changes from your working directory.
Use tags to mark important versions such as releases or milestones.
git tag v1.0
Creates a simple tag for a release or checkpoint.
git tag -a v1.0 -m "Version 1.0 release"
Creates a tag with extra metadata such as message, author, and date.
git push origin --tags
Uploads all local tags to the remote repository.
git tag
Displays every tag available in the repository.
Quick commands for checking branch names, tracked files, and commit identifiers.
git branch --show-current
Displays the active branch name.
git rev-parse HEAD
Prints the full commit ID of the current HEAD.
git ls-files
Shows all files currently tracked by Git.
git clean -f
Deletes untracked files from the working directory.
git clean -fd
Deletes untracked files and directories.
You can view a GitHub repository in a browser-based VS Code style interface by replacing part of the URL.
https://github.com/shuvabratadey/ESP-IDF-Free-RTOS
This is the standard GitHub repository link.
https://github1s.com/shuvabratadey/ESP-IDF-Free-RTOS
Add 1s after github to open the repository in an online VS Code-like viewer.
If you checked out a commit directly and want to move your branch back to that commit, these steps help recover it.
git log -1
git checkout master
git reset --hard <commit-id>
A clean starting workflow for creating a project locally and pushing it to GitHub for the first time.
git init
git remote add origin <repository-link>
git add .
git commit -m "Initial commit"
git branch -M main
git push --set-upstream origin main
Use clear commit messages, prefer main for new repositories, and avoid force operations unless you fully understand the impact.