Skip to content

Instantly share code, notes, and snippets.

@anandchakru
Last active July 24, 2017 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anandchakru/10499aed936a3b3c5ed97e217b4ae303 to your computer and use it in GitHub Desktop.
Save anandchakru/10499aed936a3b3c5ed97e217b4ae303 to your computer and use it in GitHub Desktop.
Github notes

Clone remote repo

git clone https://github.com/anandchakru/picaslide.git

Stage all new/modified files from current dir

git add .

or

git add -A

Unstaged all files

git reset HEAD .

Commit staged files into local repo

git commit -m 'commit comments'

Push local repo to [repote repo]

git push -u origin master

Reference: -u

Reference: origin

Pull changes from [remote repo] to local repo

git pull

While Pull if you see conflict, Resolve all the conflicts and do a git commit -m 'conflicts resolved' to have local repo conflict free

Status

git status

Show all non-staged changes

git diff

List Branches

git branch

Create a Branch (of current branch you are in)

git branch guestslists

Delete a Branch (error if unmerged changes exists)

git branch -d guestlists

Delete a Branch (force delete)

git branch -D guestlists

Rename Current branch

git branch -m newguestlists

Merge Branches:

  • Switch to guestlists

    git checkout guestlists
    
  • Update master branch,

    git fetch origin master
    
  • Merge master into guestlists (to ensure no conflits)

    git merge master
    
  • Merge guestlists into master

    git checkout master
    git merge guestlists
    
  • Push both to [remote repo]

    git push -u origin guestlists:master
    

Show all non-staged changes in current branch

Stash

  • Stash your changes and clean the current branch

    git stash save "Comments about changes it has"
    
  • List the stashes

    git stash list
    # stash@{0}: On guestlists: Comments about changes it has
    
  • Move back stashed changes into current branch

    git stash apply stash@{0}
    

or

git stash pop
  • Delete a stash
    git stash drop stash@{0}
    

Reference:

Github Flow Cheet sheet

Reference Videos:

clone, status, add, commit, push, pull

branch, merge, pull

stash

playlist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment