4 ms·
You got a lot of questions in there, and I'm writing in a hurry, so sorry if some of the following doesn't make sense. > Aren't the arrows all facing the wrong
by bodhi 13y ago
You got a lot of questions in there, and I'm writing in a hurry, so sorry if some of the following doesn't make sense.
> Aren't the arrows all facing the wrong way?
Technically, commits are linked to their parent (you can see this in the git log), which is why the arrows point the "wrong" way. If you think about it, a child node has a fixed number of parents, but a parent can have an infinite number of children.
> What happens to a commit after 'git reset' abandons it; can the commit be accessed ever again?
The commit doesn't go anywhere (yet). What actually happens with `reset` is a touch complicated, but basically you are changing the label of the "thing" that you are resetting to point to a different commit . After you reset, you can still `git show <sha>`, ie. the commit is still accessible, it's just not part of the "tree".
> What's the difference between reset and revert?
Reset will change labels (tags, branch heads), whereas revert just takes the commit you've given it (say `C`), inverts it (so "add line X" becomes "delete line X"), and creates a new commit that undoes (reverts) the changes in `C`.
> How can merge and rebase be trusted?
... to do what exactly? One thing to note is that git will bail out when a merge/rebase causes a conflict, and leaves it up to you to fix it.
> What are the best practices for how many branches a project should have and how & when should they be merged?
This is close to a "Emacs vs Vim"-type question (Emacs, of course ;) ). We use feature branches in our 5-developer project quite successfully, sometimes we have 10 branches in flight, and sometimes we can collapse down to `master`.
Branching is so cheap in Git that you can just use them as much as you want.
> And what are remote tracking branches?
A remote tracking branch (as far as I know) is just a setting for git saying local branch `A` will automatically use remote branch `B` for updates (push/pull) without having to tell git every time to update from `B`.