Giter Club home page Giter Club logo

gitcheatsheet's Introduction

git cheatsheet

Common commands. Easy for future use.

reset one file

git checkout HEAD -- my-file.txt

reset to remote

git fetch origin
git reset --hard origin/master

merge two commits into one

git log --pretty=oneline
a931ac7c808e2471b22b5bd20f0cad046b1c5d0d c
b76d157d507e819d7511132bdb5a80dd421d854f b
df239176e1a2ffac927d8b496ea00d5488481db5 a

git rebase --interactive HEAD~2
pick b76d157 b
pick a931ac7 c

pick   b76d157 b
squash a931ac7 c

move git repository

git fetch origin
git remote add new-origin [email protected]:user/repo.git
git push --all new-origin
git push --tags new-origin
git remote rm origin
git remote rename new-origin origin

remove local branches no longer on remote

git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done

local gitignore

.git/info/exclude

remove a folder from git tracking

git rm -r --cached path_to_your_folder/

update cached credential on macOS

git config --global credential.helper osxkeychain

rewrite the most recent commit message

git commit --amend

push a local Git branch to master branch in the remote

git push origin develop:master

git push <remote> <local branch name>:<remote branch to push into>

show file differences between staging and the last file version

git diff --staged

stash a single file

git stash push -m welcome_cart app/views/cart/welcome.thtml

undo git add

git reset <file>
git reset # unstage all changes

undo last commit

git reset --soft HEAD~1

gitcheatsheet's People

Contributors

mxiao6 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

gitcheatsheet's Issues

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.