Coder Social home page Coder Social logo

git-commands's Introduction

Git-Commands

Cloning

  • Simply clone
git clone <repo name>
  • Clone a branch
git clone -b <branch-name> <repo name>

Remotes

  • Add a remote
git remote add <remote name> <remote url>
  • Rmeove a remote
git remote remove <remote name>
  • Show remote
git remote -v

Stage Changes

  • Stage changes
git add <changes>
  • Stage hunks (May need to edit hunks with editor)
git add <changes> -p

Commit Changes

  • Commit (Opens editor for message)
git commit
  • Fixup commit
git commit --fixup <commit id to fixup> -m <additional fixup message>

Push changes

  • Push to HEAD
git push <remote> HEAD
  • Push to another branch
git push <remote> <commit>

Pull changes

  • Fetch+Merge from origin
git pull <remote> <HEAD>
  • Just fetch from remote (Not merge)
git fetch

Stashing

  • Stash away unstaged
git stash
  • Apply stash
git statsh pop
git statsh apply
  • Show stash
git stash show
  • Drop stash
git stash drop

Diffs

  • Basic diff
git diff <commit 1> <commit 2>
  • Current unstaged changes
git diff
  • Current unstaged on particular file
git diff -- <file>
  • Staged changes
git diff --staged
  • Staged changes on a particular file
git diff --staged -- <file>

Rename

  • Rename file in git tree
git mv <src> <dst>

Checkout

  • Checkout a branch (pre-existing)
git checkout <branch>
  • Create and checkout to a new branch
git checkout -b <branch>
  • Reset unstaged changes
git checkout .
  • Reset unstaged changes on a file
git checkout -- <file>
  • Reset Local Commits, commits not pushed
git reset --hard origin/<branch_name>

Configs

  • Rebase
git config pull.rebase true

git-commands's People

Contributors

nikunjsarda avatar r0ck3r008 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.