Skip to content

Latest commit

 

History

History
123 lines (100 loc) · 1.96 KB

KnowGitMore.md

File metadata and controls

123 lines (100 loc) · 1.96 KB

Git commands one should know !

Viewing branches

git branch --list

Deleting a branch

git branch -d branch_name

Git status

  • Git status gives information about the branch & files
git status

To check push/fetch origin URL

git remote -v

Git Pull

  • To gets the updates from remote repository and immediately applies the latest changes in your local.
git pull origin main/master

To undo the changes

  • We need to specify the hash code ( eg. 3321844 ) next to our commit that we would like to undo
git revert hash_code

To rename a git file

git mv old_file_name  new_file_name

Temporarily stores your modified files

git stash
  • View all of your stashes
git stash list
  • Apply a stash to a branch
git stash apply

To see all the previous commits

  • Most recent will appear first
git log

To see commits of other group authors.

git shortlog

To see details about a specific commit

git show your_commit_hash_code

To delete tracked file from the current directory

git rm file_name

To merge a specific branch feature to your directory

git merge branch_name

To integrates two branches into a single branch.

git rebase base_name

To find a good/bad commit

  • Initiate git bisect
git bisect start
  • To know about a good commit
git bisect good a123
  • To know about a bad commit
git bisect bad z123

To apply a commit from any branch and apply it to any other branch

git cherry-pick commmit_hash_code

To compare two Git files

  • To compare working directory with the local repo
git diff HEAD file_name
  • To compare two branches
git diff source_branch target_branch

There are many commands in Git

  • Use the following command in the terminal to check other Git commands
git help