Skip to content

Latest commit

 

History

History
97 lines (82 loc) · 1.73 KB

git.md

File metadata and controls

97 lines (82 loc) · 1.73 KB

Git Commands

Remove vscode from git:

git rm --cached .vscode

Squash main branch:

git reset --soft Head~3
git commit -m 'Project Created'
git push --force origin main

Add submodule:

git submodule add [url] [path](src/...)

Submodule recursive:

git submodule update --init --recursive --remote

After change password run below command:

git config --global credential.helper wincred

Log on a single line

git log --pretty=oneline

Log show indented branch-points and merges

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Delete Local Branch

git branch -D <branchname>

Delete Remote Branch

git push origin --delete <branchname>

Create branch from unpush commit on main

git checkout -b <branchname>

Create upstream for a branch

git push -u origin <branchname>

Stash (Temporary Commit)

  • staged changes
git stash
  • list stack-order of stashed file changes
git stash list
  • write working from top of stash stack
git stash pop
  • discard the changes from top of stash stack
git stash drop

Have Git in WSL use your Windows credentials

git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe"

Reset commit but keep the changes

git reset HEAD^

Resolving the issue for running git command very slow in wsl. Function must added to ~/.bashrc

function git() {
  if [[ $(pwd -P) = /mnt/* ]]; then
    git.exe "$@"
  else
    command git "$@"
  fi
}