Top most used GIT commands

Checkout GIT repository in current folder
git clone <repository name> .

Checkout GIT repository in current folder
git checkout -b <new branch name>

Push new branch changes to remote repository
git push origin <new branch name>

Cherry pick code
git cherry-pick <Commit hash string>

list all the un-tracked files
git clean -n

Remove all the un-tracked files
git clean -f

Remove all the un-tracked files and directories
git clean -f -d

Delete branch
git branch -d <branch Name>              /* local branch */
git branch -D <branch Name>              /* for delete local + remote branch */

Applying stash
git stash apply <Stash with index>

List all Stash available
git stash list

Abort merge in progress, this reverts all the files from abort
git merge --abort

Abort cherry pick that is in progress
git cherry-pick --abort

Checkout main branch
git checkout main

List All tags
git tag --list
git tag -l

List all tags in reverse order
git tag -l --sort=-v:refname # reverse

Tag current/checked out branch with tag name main_label_1
git tag main_label_1 -a
         put appropriate comment after prompt

Push created label/tag to origin
git push origin main_label_1
Or
git push origin --tags

git checkout child_branch

Merge main_label_1 tag to current branch
git merge main_label_1

git tag child_branch_label -a
git merge child_branch_label 

Comments

Popular posts from this blog

How to do AJAX using XMLHttpRequest for large data

Caching mechanisms in modern world browser

Polymorphism in Java OOP