Some useful GIT commands

  1. git branch — merged master: Prints the branches merged into master
  2. git branch — merged lists: Prints the branches merged into HEAD
  3. git branch — no-merged: Prints branches that have not been merged(By default this allows only to local branches. -a flag for all branches and -r flag for remote branches).
  4. git stash drop: Will remove the latest added stash
  5. git stash drop <stashname> : Remove a specific stash
  6. git config — list: Prints all the git configuration settings
  7. git checkout -b <branch_name> :Creates a new branch in GIT
  8. git branch -d <branch_name> : Deletes a branch
  9. git diff: Displays differences between 2 versions or between working directory or between index and most recent commit.
  10. git rerere: Stands for “reuse recorded resolution”. By using rerere, GIT remembers how we’v resolved a hunk conflict.
  11. git diff -cached: Displays the differences between working directory and the most recent commit
  12. git status: Shows the status of working tree.
  13. git rm: Removes a file from the working tree and the index.
  14. git rm -r : to recursively remove all files from a leading directory.
  15. git stash apply: Brings back the unfinished work
  16. git stash apply <stashname>: Applies the indicated stash
  17. git reset: Reverses the action of git add
  18. git commit — ammend: Changes the commit message
  19. git init -bare : Creates a bare repository in GIT.
  20. git remote add <Remote Repo URL> :adds the local repo on Git Server.
  21. git clean: Recursively cleans the working tree.
  22. git clean -x: Ignored files are removed
  23. git diff <commit#1> <commit#2>: Prints differences between two commits.
  24. git branch -v: Shows latest commit associated with each branch.
  25. git grep: Allows us to search for a string or regular expression in any committed tree or the working directory.
  26. git blame -L <file_name>: Displays commit and name of a person responsible for making change in that line.
  27. git gc: Performs garbage collection of repository. Cleans unnecessary files.
  28. git archive: Creates a tar or zip file including the contents of single tree from local repository.
  29. git fsck: Performs integrity check of the Git file system.
  30. git prune: Used to remove objects that are no longer pointed to by any object in any reachable branch.
  31. git ls -tree: Shows a tree object. Includes name of each item and SHA-1 value of blob or tree that it points to.
    e.g., git ls-tree master
  32. git cat -file: Used to view the type of an object through SHA-1 value.
  33. git show: Shows information about a git object.
    e.g., git show commit 6d-d2c056e96b4
    Author: User <john@doe.com>
    Date: Thu Jul 6 09…….and so on
  34. git tag: Tags a specific commit to a human readable handle that will never move
    git tag -a v5.0 -m ‘version 5.0 tag’

--

--

--

I am a software engineer. I specialize in JavaScript, React.js, NodeJS, Docker and Kubernetes.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MOST USED DevOps TOOLS AND THEIR KEY FEATURES

HTTP/1.1 vs HTTP/2.0

If You Are Learning Golang, Remember These 10 Commands

Deploy a Streamlit App on Heroku with OCR

Algorithms in Ruby: Fibonacci sequence

How to configure EC2, EBS, and S3 in AWS using AWS CLI

Web Development Courses that you should take today…

Building echobot on line with flask python and pagekite

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nishit Ranjan

Nishit Ranjan

I am a software engineer. I specialize in JavaScript, React.js, NodeJS, Docker and Kubernetes.

More from Medium

how to use git or Github?

GitHub and the command line: “Gitting” better at coding:

Cute cat looking at camera

GIT Commands

How to install Git