Linktail

little code and rest is about life

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
The 43 best websites for learning something new — March 4, 2017

The 43 best websites for learning something new

Knowledge media

TED/TED-Ed — spreading ideas, usually in the form of short, powerful talks

Curiosity  —  hundreds of thousands of quality videos for your interests

Investopedia —  largest financial education website in the world

Open Culture  —  compendium of free learning resources

HowStuffWorks  —  explains thousands of topics, from ESP to lock-picking

Popular Science  —  magazine on current science and technology

AEON  —  profound and provocative thinking for the web

The Atlantic  —  We know it’s a curveball… but it’s awesome!

Book of Life  —  for the most substantial things in your life

Matter  —  Award winning publishing platform and studio for storytellers

Blogs

Wait But Why  —  a stick-figure-illustrated blog about almost everything

Brain Pickings —  an inventory of cross-disciplinary interestingness

Backreactions —  theoretical physicist on recent news in physics

You Are Not So Smart  —  an attack on common misconceptions we all have

Hello Internet —  Brady Haran and CGP Grey discuss. It’s worth listening.

Whizzpast  —  a very impressive history blog read

Barking up the wrong tree — science-based insights on how to get ahead

20 Minute VC  —  Want to get funding or begin a career in VC? Start here!

Engaging tools

Kahoot  —  engage with learning games, made from multiple choice questions

Lumosity —  challenge your cognitive abilities with scientific brain games

Memrise —  learning languages and vocabulary, made joyful

Macat —  Platform for developing critical thinking

Duolingo  —  get your language education for free

Degreed —  the lifelong learning platform, aggregating everything you do

Communities

Quora  —  connecting people who have knowledge to the people who need it

Socratic — Answers and content from a huge community of teachers

Declara  —  discover, collect, and share knowledge with like-minded people

Stack Exchange — expert Q&A communities, including Stack Overflow

Zooniverse  —  world’s largest platform for people-powered research

Instructables —  user-created and uploaded do-it-yourself projects

Academia  —  Share and discover academic papers on all topics

Course platforms

Coursera —  getting you access to the world’s greatest education

Highbrow  —  5-minute courses brought to your inbox every day

Udemy  —  follow courses on yoga to photography–and much, much more

FutureLearn  —  go through courses from universities and cultural institutions

MIT OpenCourseWare —  virtually all MIT course content

Udacity  —  acquire skills through series of courses and hands-on projects

edX  —  access high quality education, including from MIT & Harvard

Codeacademy  —  learn to code interactively, for free

Khan Academy  —  work on the skills you choose at your own pace

Academic Earth  —  free college courses and ongoing series of original videos

Chesscademy  —  free online lessons for those keen to play chess

How to start a startup —  The best one-stop-shop for entrepreneurs