Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

99% of the time I use:

- git status

- git add ...

- git reset ...

- git commit ...

- git log ...

- git push/pull ...

I guess that's "the basics" - what command should I learn next?



Command to learn: - git rebase (if you learn everything you can do with this command, you'll pretty much know git inside and out)

Other useful stuff: - git diff - git diff --cached - git log --graph --decorate --pretty=oneline --abbrev-commit --all - git cherry-pick - git stash


git bisect is a powerful one i use to identify when a given bug was introduced


Install git achievements (https://github.com/icefox/git-achievements) and get free internet points to expore them all.

Disclaimer: wrote this a few years ago and it has way more users than I ever would have thought.


I use this command constantly:

http://blog.kfish.org/2010/04/git-lola.html

Being able to see the graph structure made it far easier for me to get a grasp git's general structure and flow on a higher level.


Looking at the history tree with all the branches and remote branches is a great way really understand Git.

More powerful history browsers to "lola": * gitk (graphical, developed in git's own repo) https://lostechies.com/joshuaflanagan/2010/09/03/use-gitk-to... * tig (console) http://jonas.nitro.dk/tig/manual.html


> git rebase -i Very useful!


Yes, but watch out if you've already pushed to remote branches or even done merge/rebase with other local branches. You're rewriting history.


I most often use it because I forgot to include a certain file in my most recent commit. I'll just commit that file then rebase -i to merge the two.


If you want to alter the most recent commit, you can 'git commit --amend', no need to rebase.

http://git-scm.com/book/en/v2/Git-Basics-Undoing-Things


For quick changes to the most recent commit, a handy alias to put in your ~/.gitconfig is:

  fixup = commit --amend -C HEAD
That way you can stage whatever you forgot, and then do `git fixup` to update the latest commit with it. Saves a little bit of typing :)

I do love `rebase -i` for anything more complicated though.


that flows naturally into git reflog -- to get you out of a botched rebase with git reset :P


bisect.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: