Skip to content

Instantly share code, notes, and snippets.

@RajaJaganathan
Created January 14, 2016 11:52
Show Gist options
  • Save RajaJaganathan/b2ed0eaeef6ab53d71cd to your computer and use it in GitHub Desktop.
Save RajaJaganathan/b2ed0eaeef6ab53d71cd to your computer and use it in GitHub Desktop.

Git Commands:

Revert all local file changes: git checkout . git clean -f (untracked files) git clean -d (untracked directories)

Create new branch: git checkout -b develop git push -u origin develop (create remote branch but create local branch) git checkout -b feature/scaffolding develop (create branch out of another branch) git branch -d branch_name (delete branch)

Add files into stage: git add -A (all files) git add . (exclude deleted files and untracked files) git reset (unstage all files) git add -A then git reset -- some/dir/to/unstage (add all except one folder/file)

Diff: git difftool git difftool --cached (git diff --staged)

Rename branch locally and remotely:

  git branch -m old_branch new_branch         # Rename branch locally    
  git push origin :old_branch                 # Delete the old branch    
  git push --set-upstream origin new_branch   # Push the new branch, set local branch to track the new remote

git other:

  git config --global push.default current
  git config user.name

How to merge:

Step 1. Update the repo and checkout the branch we are going to merge

  git fetch origin
  git checkout -b feature/scaffolding origin/feature/scaffolding

Step 2. Merge the branch and push the changes to GitLab

  git checkout develop
  git merge --no-ff feature/scaffolding
  git push origin develop

Frequent update from develop to avoid merge conflicts: ☐ git co develop ☐ git pull

then

☐ git co feature/devlogin ☐ git merge develop

http://stackoverflow.com/questions/12903338/angularjs-dependency-injection-of-value-inside-of-module-config

How to diff the same file between two different commits on the same branch: ☐ git diff HEAD1 HEAD -- main.c ☐ git difftool HEAD1..HEAD -- HTML/attendance.html

Sublime/Chrome DevTool Shortcuts:

☐ ⌃Tilde:Show console ☐ ⌘D:Select next occurrence ☐ ⌥- : Jump to previous editing location ☐ ⌥+ : Jump to next editing location ☐ F8 or ⌘:Pause/ Continue ☐ F10 or ⌘':Step over ☐ F11 or ⌘;:Step into ☐ ⇧F11 or ⇧⌘;:Step out

Sublime Useful Plugins:

☐ AutoFileName ☐ JSCS-Formatter

Setup: Git diff tool installation

☐ brew install kdiff3 ☐ brew linkapps qt ☐ git config --global merge.tool kdiff3 ☐ git config --global diff.tool kdiff3 ☐ git config --global difftool.prompt false

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