Back to Browse

Git - Most useful GIT COMMANDS

301 views
Jun 17, 2020
20:53

GIT most used commands =================== Git init — Initialize git Git status — check the status Git add — add files to stage git status -s — display files and status Git log — view logs Git log —oneline — Logs can be viewed in one line Git diff — updates on the file from HEAD Git commit -m “message” — Commit the files to local repository Git config —global user.name — Add user name to git config Git config —global user.email — Add user email to git config Git config —list — list all the git configuration Git remote add origin “git repo” — Add Remote repository to the git Git remote -v — View Remote repository details Git push origin -u master — Push the local repository changes to remote Git diff-tree -r Commit_ID Git reset --hard Commit_ID — Resets all local repository,stage and working copy to HEAD Git reset —mixed Commit_ID — Resets all local repository, stage to HEAD and no changes in working copy Git reset —soft Commit_ID — Resets only local repository and no changes to stage & working copy Git branch branch_name — Create a branch Git checkout branch_name — CheckOut Branch Git checkout -b branch_name — Create a new branch and checkout to it Git branch —list — List all the branches Git push origin -u branch_name — Push the local branch to remote git merge Branch1 — Merge branch ‘B’ into current branch git fetch —to fetch the remote changes into local repository git pull — apply remote changes to local working copy Git rebase master — Rebase the current branch on master Git clean -n -d — list all the files would delete which are untracked Git clean -f -d — Delete all the files and directories which are untracked Git branch -d branch_name — if the branch is fully merged, delete the branch Git branch -D branch_name — force delete irrespective of merge the changes or not git push origin --delete feature — delete remote branch Git Tags: ========= Annotated tag : git tag -a tag_name -m "tag_message" Light weighted tag : git tag tag_name push tag to remote: git push origin tag_name git push origin --tags Delete local tag : git tag --delete tag_name git tag --d tag_name1 tag_name2 Delete Remote tag : git push origin --delete tag_name git push origin --d tag_name1 tag_name2 Checkout a branch to tag: git checkout -b branch_name tag_name Git stash: ========= git stash — create a stash git stash save “StashName”. Or git stash push -m "modified” — create stash with name instead of HEAD version(default) git stash push -m "message" file — stash a file git stash -u — stash untracked files Git stash list — list all the stashes git stash branch branch_name stash@{stash_index} — stash into a branch Git stash apply stash@{stash_index} — apply stash changes into current working dir without deleting the stash Git stash pop stash@{stash_index} — apply stash changes into current working directory by deleting the stash git stash show stash@{stash_index} — show the differences between stash and HEAD git stash show -p stash@{stash_index} — This shows the diff in content git stash drop stash@{stash_index} — drop the stash Git stash clear — clear all the stashes

Download

1 formats

Video Formats

360pmp428.6 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Git - Most useful GIT COMMANDS | NatokHD