Linktail

little code and rest is about life

Emojis on Medium — August 20, 2017

Emojis on Medium

Click here

Advertisements
Tips and tricks for Medium writers — August 19, 2017
Our 6 Must Reads if You’re at a Startup With 30+ People — July 17, 2017
Git Commands Cheat Sheet — April 23, 2017

Git Commands Cheat Sheet

Create

  • Create a new local repository
    • git init
  • Clone an existing repository
    • git clone [your_repository_url]

Track chages

  • File status about local repository
    • git status
  • Chages to remote[tracked] files
    • git diff [source_branch] [target_branch]

Add file

  • Add all changes in commit
    • git add .
  • Add single file in commit
    • git add -p [your_file_name]

Commit file

  • Commit previously chaged file
    • git commit
  • Commit all local changes
    • git commit -a
  • Add single file in commit
    • git add -p [your_file_name]
  • Amending the most recent commit message in editor
    • git commit --amend
  • Amending the most recent commit message with new message
    • git commit --amend -m "New commit message"

See history

  • See all commit log details
    • git log
  • See commit log details about single file
    • git log -p [your_file_name]
  • Only the commits of a certain author
    • git log --author=[author_name]
  • Compressed log in one line:
    • git log --pretty=oneline
  • Log details only for changes files
    • git log --name-status

Command for branch

  • See all branch
    • git branch -av
  • Switch exisiting branch
    • git checkout [your_branch_name]
  • Create new local branch and switch to new branch
    • git checkout -b [your_branch_name]
  • Delete a local branch
    • git branch -d [your_branch_name]
  • Delete a remote branch
    • git branch -dr [your_branch_name]
  • Add tag on current commit
    • git tag [your_tag_name]

Remote

  • See all remote repository url
    • git remote -v
  • See info about remote repository
    • git remote show [remote_repository_url]
  • Add remote repository
    • git remote add [remote_repository_url]
  • Fetch all branch structure from remote
    • git fetch

pull

  • Fetch all changes from remote directory
    • git pull
    • git pull [remote] [branch]

push

  • Fetch all changes from remote directory
    • git push
    • git push [remote] [branch]
  • Publish your tags
    • git pull --tags

merge

  • Merge branch into your current HEAD
    • git merge [your_branch_name]
  • Solve conflics using mergetool
    • git mergetool

rebase

  • Rebase with HEAD branch
    • git rebase [your_branch_name]
  • Continue rebase after resolving conflicts
    • git rebase --continue
  • Abort rebase
    • git rebase --abort

reset

  • Discard all changes in your local branch
    • git reset --hard HEAD
  • Discard local branch changes for single file
    • git checkout HEAD [your_file_name]
  • Revert specific commit
    • git revert [commit_hash]
  • Reset your local branch with specific commit forcefully and discard local changes
    • git reset --hard [commit_hash]
  • Reset your local branch with specific commit and discard local changes
    • git reset [commit_hash]
  • Use colorful git output
    • git config color.ui true

References

Whenever you have more than 1 option. remove one as soon as possible to be happy in life ~ Amit Shekhar — April 21, 2017
Online Photoshop Kind tool — April 19, 2017
Robotic- Human Tongue — April 18, 2017
Operating Systems Animations — April 8, 2017
When Pixels Collide Redit(April Fool Day) — April 7, 2017
16 Mind-Blowing Illusions That Will Trick Your Brain — March 25, 2017