Skip to content

Common git Commands

1. Config

1.1. Case sensitive

git config core.ignorecase false

2. Branch

2.1. Set current branch to track remote branch

$ git branch -u origin/remote-branch

2.2. Create local branch to track remote branch

git checkout -b local-branch origin/remote-bracnh
Branch local-branch set up to track remote branch remote-bracnh from origin.
Switched to a new branch 'local-branch'

3. Submodule

3.1. Adding a submodule

git submodule add git@github.com:[path_to_your_submodule.git] [submodule-path]

3.2. Clone git repository with submodules

Clone a repository, check out and init any possible submodules the repository has.

git clone git@github.com:[path_to_your_git_with_submodules.git] 
git submodule init
git submodule update

3.3. Pull the main repository and also it's submodules.

git pull --recurse-submodules

3.4. Update current repo with submodules

git submodule update

3.5. Remove a submodule

A bit tricky process, it involves some steps - Delete the relevant line from the .gitmodules file. - Delete the relevant section from ::.git/config. - Run git rm --cached [path_to_submodule] (no trailing slash). - Commit and delete the now untracked submodule files.

3.6. References