Skip to content

Git

User Profile

git config --global user.email "[email protected]"
git config --global user.name "Serge Kurian"

Repository Management

Init with Main Branch

git init -b main

Create New Repository

echo "# delete" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin [email protected]:jdedev/delete.git
git push -u origin main

Branches

To be added


Common Git Commands

Commit

git add . ; git commit -m "update" ; git push ; git status

Restore Unstaged Changes

git restore .

Submodules

Add Submodule

git submodule add [email protected]:jdedev/doc_git.git

Init/Pull Submodules (after clone)

git submodule update --init

Update Submodules (get latest changes)

git submodule update --recursive --remote

Clone and Check-out Submodules

Missing submodules are cloned.
All submodules are checked out correctly.
The latest changes are pulled from each submodule’s remote repository.

git submodule update --init --recursive
git submodule foreach --recursive git reset --

Pull submodules

git pull --recurse-submodules
git submodule update --remote --merge