Giter Site home page Giter Site logo

git-cheat-sheet's Introduction

git cheat sheet

Simple cheat sheet used to remember a few useful git commands

general flow

1. git fetch origin
2. git merge origin/BRANCH_TO_BE_MERGED (git diff BRANCH origin/BRANCH to see changes)
3. git checkout -b BRANCHNAME

4. git add
5. git commit -m "MESSAGE"
6. git push -u origin BRANCHNAME
7. (Web) create PR if applicable

8. git rebase -p origin/BASEBRANCH
9. git push -f

(web)
10. (Web) Merge PR -> Delete branch
11. git checkout develop
12. git fetch origin
13. git merge origin/develop

(command line)
10. git checkout develop
11. git merge --no-ff BRANCHNAME
12. Resolve conflits if any with 'subl filepath' (or any other editor) then git add . and git commit
13. git push origin develop

14. git branch -d BRANCHNAME
15. (web) delete branch
16. git tag TAGNAME
17. git push --tags

git stashing

1. git stash save STASHNAME
2. git stash list
3. git stash apply stash@{POS}
4. git stash drop stash@{POS}

3. git stash pop

git rewriting history !!! NOT SAFE !!!

1. git reset COMMITHASH
2. git push -f	

git deleting tags

1. git tag -d TAGNAME (local)
2. git push --delete origin TAGNAME (remote)

git search by commit message

1. git log --all --grep='TERM' 

git search by code

1. git log -p --all -S 'CODE_SNIP' --until=YYYY.MM.DD

git show most changed files

1. git effort --above COMMITCOUNT -- --after="one month ago" 

git check last versioning

1. git log -p --all --follow PATH (source/build.gradle for android)

git update remotes list

1. git remote prune origin 

git applying gitignore for repository existing files (http://stackoverflow.com/a/7532131)

1. git ls-files -ci --exclude-standard
2. git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
3. apply-gitignore = !git ls-files -ci --exclude-standard -z | xargs -0r git rm --cached

Recommended reads

Git from the inside out

GIT: FETCH AND MERGE, DON’T PULL

Don't Be Scared of git rebase

http://nvie.com/posts/a-successful-git-branching-model/

git-cheat-sheet's People

Contributors

fibelatti avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

leobrujah

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.