git pull
git merge x
git checkout [-b] foo
git commit
git push git pull
git merge x
git checkout [-b] foo
git commit
git pushobjects: blobs, trees, commits, annotated tags
refs: branches (local, remote-tracking), tags, HEAD
other: working tree, index (aka cache aka staging area), remotes
There's lots of good guides out there: git from the bottom up, git for computer scientists, and the git parable are some that spring to mind. The Git Book is also excellent but it's more than 15 minutes of your time.
All the commands become way less mystifying when you understand what they are manipulating. You'll never get into a state where you want to `rm -rf` the entire repo and start with a new clone. There will hopefully be no more teeth grinding or keyboard mashing.
I've used a lot of VCSs over the years (rcs, sccs, cvs, subversion, clearcase, mercurial, git) and I swear git is the one I find least frustrating. The others may have had simpler interfaces, but they were either conceptually more complex, overly rigid in their design and behavior, or both (looking at you clearcase).
Look, I get it: a lot of folks see git as a necessary evil that's part of their day job. I disagree. I think it's really worth spending the time to learn well, probably like you invested some time in your editor and other tooling.
I mean, it's easier than C++. :-)
Most of the time, I'll humbly trade "overly rigid in their design and behavior" for "simpler interfaces". Please master VCS, discipline me !
So I usually do whatever I can to keep a single straight-line master history.
I branch off for a task, then after a while my branch isn't joined at the tip of master. So I rebase locally until it is. Then when the PR happens, master gets my changes added to the top, with no extra noise from merge commits.
Even if the local-rebase workflow is slightly more complicated, the payoff is a really clean history, making future reasoning about branches much easier. Not to mention merge conflicts are easier to solve when you rebase early & often.
This step is when newbies get confused because the diffs are the wrong way, and I've seen people often losing merge hunks from master when there are conflicts which can be disastrous (not a git issue, I've seen people do the same in SVN).
The proper solution IMO would be for git to have a "merge --reintegrate" which would do the opposite merge: take the main branch and merge the current feature branch to it... after success, you have a new feature branch.
This is why I also prefer rebase and cleaner history (but a common mistake here is to squash after PR approval... that should be done before, not after).
Consider finding peace by inverting your perspective: if your organization’s development process (for whatever reason, many of them legitimate) involves a crazy train-track of features being developed in parallel, isn’t it great that you're all at least using something that can keep track of it?
For a small team that should be unnecessary.
Frequent rebasing when you’re on a side branch of development is smart, but doesn’t conflict with my point.
Also, really, who looks back into the depths of history? There’s a reason a lot of backup schemes rotate a set of tapes over 30 or even 14 days. For that reason I am not a fan of rewriting history for “clarity”: I consider it wasted effort.
For the same reason I don’t care about branches for explorations that turned out to go nowhere — just mark the head abandoned and stop worrying about it.
Then there's of course `git log`, `git diff`, and `git status`, but I presume you know about those as well.
Unfucking thing is what of most of my knowledge of git goes to. Committing in the wrong branch, the wrong files, starting from the wrong commit, etc... Before you push, almost all mistakes are fixable, but it requires knowing a few more commands.
Then there are the project specific things. For instance, I worked on a project where we didn't have a central server we could push to and pull from (airgap). So we had to work with bundles. Git does that really well (it really is decentralized), but it is uncommon. Some people prefer a rebase-based workflow, some use cherry-picking extensively, some projects are more prone to conflicts than others, etc...
git reset --hard git reset --soft HEAD~1I throw in a `git reflog` once in a while, and the other day I patted myself on the back for my first use of `git tag -a mytag -m "This is my first tag!"` followed by `git push origin mytag`. I felt like god
now as much as I hate Xcode, its UI for looking at all my current changes and staging them by blocks of line for commit is like a superpower. as a solo developer working on brand new code, not all of my lines of thinking follow very atomic git commits, so it's nice to separate, say, some refactoring code from some actually new functionality when committing changes
git log
git show
git status
git blame
git diff
git add
git reset git add
git blame
git branch
git checkout
git cherry-pick
git clone
git commit
git diff
git fetch
git log
git merge
git pull
git push
git reset
git rm
git stash
git status
17 commands in total. I don't think it is possible to be a professional software engineer without being familiar with them. Granted, some of these you may need more frequently than others.My guess is, the OC relies on their IDE/editor for the functionality provided by some of these commands. But then, why not just go all the way. Just use all VC features provided by your IDE, and claim that you need zero git commands.
(well... it's about 1% because I do everything using the eclipse git UI, but that's the same behavior you get from that commands)
If you teach "checkout to move around and add -b when moving to a new branch the first time" that works pretty well
git switch -c foo
git push
> did you mean git push --args-with-branch-name?
sigh, copy, paste, enterBasically you can stop using checkout.
*edit*: fixed switch branch creation parameter.
I will keep using them so I can keep using old software. How new is it? Does ubuntu or debian have it?
git rebase HEAD~2 -i
git commit —amend