Configs

Git-GitHub Git

Install git

Git usually comes pre-installed with most Linux distros, but you if not in yours, you can install it via you package manager (apt, dnf etc) as instructed on Git download page:

# For Fedora:
sudo dnf install git

Set name and email

Referring the First-Time Git Setup page:

You can also refer my git config in the .gitconfig file

More about Git config

The local config is in the .git/ folder of your project repository. To make changes to local config, just remove the --global flag (or you can pass the --local flag to be more explicit). You can have multiple lines setting the same variable in the config file; the last i.e. lowest line setting the variable is the final value of that variable

# Add a variable value
git config --add someSection.someKey "someValue"
# List config
git config --list
# Get value of specific variable
git config --get someSection.someKey
# Remove the variable
git config --unset someSection.someKey
# Remove all lines setting the variable
git config --unset-all someSection.someKey
# Remove an entire section
git config --remove-section someSection

In total there are 4 levels where the Git config can be stored. For the same variable name, the higher-precedence one replaces the lower-precedence one. The locations are as mentioned below, in increasing order of specificity (and thereby precedence). :

  1. System-wide config: Stored as /etc/gitconfig, it’s for ALL USERS on your system
  2. Global config: Stored as ~/.gitconfig, it is the global config for ALL REPOS of THAT USER
  3. Local config: Stored as .git/config in your project repository, it’ defined for that SPECIFIC REPO
  4. Worktree config: Stored at .git/config.worktree it’s defined for that PART of the project repo

In most cases, you’ll just be using the Global config for all your projects and sometime maybes the Local config

GitHub SSH setup

Also try cloning any GitHub repo via the SSH method url: git@github.com:USERNAME/REPONAME.git

References:

Removing old SSH Identity

SSH identities are stored in ~/.ssh folder and SSH manages these identities


The usual development workflow

Let’s call the derived child branch you’re working on as DEV and the base branch you’re syncing it with as MAIN

# Before starting work, sync DEV with MAIN
git switch DEV
git fetch origin
git rebase origin/MAIN

# Do work, Commit and Push to your DEV
git add .
git commit -m "your message"
git push origin DEV


# Create a PR from DEV → MAIN
# Squash and Merge (cleans up commit history)

# After merge, sync DEV with updated MAIN
git switch DEV
git fetch origin
git rebase origin/MAIN
#
# If rebase rewrote DEV's history, your local branch will now differ from origin/DEV
# VSCode and `git status` may show "diverged" (such as 1 ahead, 1 behind)
# This is because rebasing rewrites commit hashes, even if content is identical
# To resolve this and sync your local DEV with origin/DEV, overwrite the remote with:
git push --force-with-lease origin DEV