Skip to content

Instantly share code, notes, and snippets.

@101t
Last active August 4, 2023 06:09
Show Gist options
  • Save 101t/7c38cc79b5dc7c75a6a3851efa3c7c93 to your computer and use it in GitHub Desktop.
Save 101t/7c38cc79b5dc7c75a6a3851efa3c7c93 to your computer and use it in GitHub Desktop.
Git Commands Hot and simple tutorials

Git repositories with Submodules

clone new repository with submodules

git clone --recurse-submodules -j8 git://github.com/foo/bar.git

Source: here

Update sub-repositories in main repository tree

git submodule update --remote --merge

Source: here

Simple Commands for "git"

Download Specific version of Single Branch:

git clone -b 0.7.0 --single-branch https://github.com/spchuang/videojs-markers.git

Reference here

Adding github push alias (shortcut) in .bashrc file

alias push_github='echo "Enter commit message : " && read MSG && git add . && git commit -m "$MSG" && git push'

Print git history in pretty way

git log --pretty=oneline --graph --decorate --all

To remove un-wanted directory from git manually:

git rm -r --cache .idea/

I modified code on protected branch, ohh!, now I want to move it to new branch

to grap changes on protected branch

git stash
# create new branch
git checkout -b new_branch
# pop your modified code on new_branch
git stash pop

Get remote branch that does not exist on your local git repo.

git fetch origin remote_branch_name
git checkout -b remote_branch_name FETCH_HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment