Giter Club home page Giter Club logo

git-notes's Introduction

Joegle - Git Notes

See ‡ README section (bottom) for install notes

Inbox

Setup checklist

  • [ ] Place key in github
  • [ ] git lol

Comparing / Diff

  • Diff what is staged
    git diff --staged
        
  • Diff between dates
    git diff [--stat] @{2017-03-01}..@{2017-04-01}
        
  • Temporarily ignore changes in file (then undo)
    git update-index --assume-unchanged <file>
    git update-index --no-assume-unchanged <file>
        
  • See what has changed
    git log --since="1 week ago" --until="1 day ago" -p
        

Basics

  • init a repo
    git init
        
  • Add empty folder
    • Add .gitignore to folder with:
      *
      !.gitignore
              
  • Unstage files
    git reset <filePath>
        
  • stop tracking a file (and start again)
    git update-index --assume-unchanged [<file> ...]
    git update-index --no-assume-unchanged [<file> ...]
        

Config

  • List git aliases
    git config --get-regexp alias
        
  • git lol alias
    git config --global --add alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
        

Branching

  • create branch
    git branch <branch>
        
  • delete branch
    git branch -d <branch>
        
  • push branch and remember destination so you can just do ‘git push’ next time
    git push -u origin <branch>
        

Fixing

  • Remove every line from history matching sed
    git filter-branch --tree-filter 'sed -i "/sensitive information/ d" filename' -- --all
        
    • if you know the first commit
      git filter-branch --tree-filter 'sed -i "/sensitive information/ d" filename' <commit>..HEAD
              
  • Remove every line from history that has word
    git filter-branch --tree-filter "find . -type f -exec sed -i -e '/$*word/d' {} \;"
        
  • change password in every commit to new string
     git filter-branch --tree-filter "find . -type f -exec sed -i -e 's/originalpassword/newpassword/g' {} \;"
        
  • check for data
    git filter-branch --tree-filter "grep -r originalpassword * || true"
        
  • remove file from history
    git filter-branch -f --tree-filter 'rm -f full/path/file.js' HEAD
        
  • Backs ups are in .git/refs/original and can be removed (just one or all refs)
    git update-ref -d refs/original/refs/heads/master
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
        
  • Reattach head at point
    git checkout <sha>
    git branch my-new-branch -f
        
  • Renaming an author

Mutating

  • Pull versions of files from a branch
    git checkout branch -- path path path
        
  • Add a file you forgot in the last commit
    git add file-that-i-forgot.txt
    git commit --amend --no-edit
        
  • Put a commit “on top” of current point
    git rebase -i commit
        
  • delete file from git and disk
    git rm path
        
  • remove untracked files (Reset directory to HEAD)
    git clean -fd
        

Remotes

  • change remote to ssh so that it doesnt ask for password
    git remote set-url origin  [email protected]:joegle/git-notes.git
        
    • Stored in .git/config/
  • View existing remotes
    git remote -v
        

Syncing

  • List untracked files
    git ls-files . --exclude-standard --others
        
  • List ignored files
    git ls-files . --ignored --exclude-standard --others
        
  • Check if all branches are up to date with remote
    git remote -v update
        

‡ README

Todo

git-notes's People

Contributors

joegle avatar

Watchers

 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.