Honestly I still find a lot of engineers don't know git properly. Like they know enough to commit and push but that's about it. It really helps to understand everything git has to offer.
Absolutely. When I get people into learning Git, I start with the obvious (checkout, commit) move to the essential (branches, forks) and then usually say "When you're comfortable with that, start playing around with rebase. When you get into trouble with that, come talk to me again, because that's the key learning moment."
I've learned more messing up when using fancy git rebase stuff than any tutorial.
O'Reilly have a free book on Git that is amazing. I find this to be the perfect level of detail. Easy to enough to read in a short enough time, detailed enough to grasp the magic under the hood.
Yes, and in the vein of this git became way less scary after learning how it works this course helped a lot (unfortunately paid but a lot of businesses have a licence - https://www.pluralsight.com/courses/how-git-works).
Using rebase results in a cleaner history and simplified workflow in many cases. However it also means that when you have a disaster, it can be truly unrecoverable. I hope you have an old backup because you told your source control system to scramble its history, and you don't have any good way to back it out later.
For those who don't know what I mean, the funny commit ids that git produces are a hash signifying the current state of the repository AND the complete history of how you got there. Every time you rebase you take the other repository, and its history, and then replay your new commits as happening now, one after the other. Now suppose that you rebased off of a repository. Then the repository is rebased by someone else. Now there is no way to merge your code back except to --force it. And that means that if your codebase is messed up, you're now screwed up with history screwed up and no good way to sort it out.
That result is impossible if you're using a merge based result. The cost is, though, that the history is accurately complicated. And the existence of a complex history is a huge problem for useful tools like git bisect.
I'll have to add `git reflog` for instances where you've felt that you've completely screwed up something as one can always move back to a previous state. I think this is essential.
A useful one that I'll add is what I call the sword command:
`git log -S<word>`
This one allows one to list commits that contain a particular change. This has been useful in tracking down old changes
I know you're probably just trolling but I'll take the bait — I'd put all of these six before any of those three:
git pull
git clone
git status
git commit -a
git push
git diff
I mean, the ones you mentioned are pretty useful, but if you don't have a repo in the first place, even git-log isn't going to be very useful; and if you're branching and rebasing, you probably have to commit first.
(I actually prefer Magit, to the point where I sometimes run Emacs just for Magit when I'm using a different IDE.)
Things that really helped me understand git as a tree of references.
Git reset —soft and git reset —hard
Git cherry-pick
Git rebase
Git reflog
Git stash
Understanding this makes you able to manipulate branches and commits like a wizard. Once I learnt those, I can get myself out of the hairiest git problems.
RangerScience|6 years ago
I've learned more messing up when using fancy git rebase stuff than any tutorial.
james_s_tayler|6 years ago
https://www.oreilly.com/library/view/git-pocket-guide/978144...
Jsharm|6 years ago
I also use magit (https://magit.vc/) - inside spacemacs (http://spacemacs.org/)
mooreds|6 years ago
I found this zine (not free) to be helpful:
http://ohshitgit.com/
333c|6 years ago
btilly|6 years ago
Using rebase results in a cleaner history and simplified workflow in many cases. However it also means that when you have a disaster, it can be truly unrecoverable. I hope you have an old backup because you told your source control system to scramble its history, and you don't have any good way to back it out later.
For those who don't know what I mean, the funny commit ids that git produces are a hash signifying the current state of the repository AND the complete history of how you got there. Every time you rebase you take the other repository, and its history, and then replay your new commits as happening now, one after the other. Now suppose that you rebased off of a repository. Then the repository is rebased by someone else. Now there is no way to merge your code back except to --force it. And that means that if your codebase is messed up, you're now screwed up with history screwed up and no good way to sort it out.
That result is impossible if you're using a merge based result. The cost is, though, that the history is accurately complicated. And the existence of a complex history is a huge problem for useful tools like git bisect.
dwoot|6 years ago
A useful one that I'll add is what I call the sword command: `git log -S<word>` This one allows one to list commits that contain a particular change. This has been useful in tracking down old changes
kragen|6 years ago
(I actually prefer Magit, to the point where I sometimes run Emacs just for Magit when I'm using a different IDE.)
nojvek|6 years ago
Git reset —soft and git reset —hard
Git cherry-pick
Git rebase
Git reflog
Git stash
Understanding this makes you able to manipulate branches and commits like a wizard. Once I learnt those, I can get myself out of the hairiest git problems.
jimpudar|6 years ago
[0] https://www.syntevo.com/deepgit/
bshacklett|6 years ago