Coder Social home page Coder Social logo

git-snippets's Introduction

git-snippets

Collection of useful git snippets

Table of Contents

About

This is just a bunch of git related snippets. Collected from around the internet.

Snippets

Delete untracked files

git clean -fn

Set local branch to track another local branch

git branch --set-upstream BRANCH ANOTHER_BRANCH

Clear git cache and add files back

git rm -r --cached .
git add .
git commit -m "fix .gitignore"

Unstage a file

git reset HEAD FILENAME

Undo local changes to file

git checkout -- FILENAME

Undo the last local commit

To unstage changes

git reset HEAD~1

To completely undo

git reset --hard HEAD~1

Create tracked local branch

git checkout -b NEW_BRANCH
git push --set-upstream ORIGIN NEW_BRANCH

Undo a merge

git merge --abort

Compare commit messages on two branches

git log --cherry-mark --oneline A_BRANCH..ANOTHER_BRANCH

See the files changed in a specific commit

git diff-tree --no-commit-id --name-only -r THE_COMMIT_ID

Get commits per author

git shortlog -sn --all --no-merges

Configure your details

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Update and merge your current branch with a remote

if ORIGIN is the remote repository, and MASTER the remote branch.

git pull ORIGIN MASTER

See previous git commands executed

history | grep git

Delete all untracked files and directories

git clean -f -d

Push to new remote branch and set as upstream

if ORIGIN is the remote repository, and MASTER the remote branch.

git branch -u ORIGIN/MASTER

Search for string

git grep 'STRING'

Get commits for a author

git log --author 'AUTHOR'

License

MIT

git-snippets's People

Contributors

tiaanduplessis avatar

Watchers

James Cloos 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.