In a rebase, you usually are working on a feature branch or locally unique version which you look at and think is “ours”, and which you want to port “theirs” into, but from git’s perspective in a rebase it’s actually the opposite. git rebase likely has an opposite idea than you do about which branch is “ours” vs. ![]() In a rebase, Branch A is considered “ours” ( git checkout -ours can be used in a conflict to get this version) because it’s where we started working from git’s perspective, and Branch B is considered “theirs” ( git checkout -theirs also exists) because from git’s perspective those are the “foreign” commits to port. For instance, you might rebase on top of master to catch your branch up to the current state of the world in your feature branch. That way, you can “catch up” to other branches by re-writing git history in your local git. Git rebase in its simplest form is a command which will “port” another branch (Branch A) into the branch where you are currently working (Branch B), by applying all of your unique commits from Branch B on top of Branch A and replacing Branch B with this revised version. What is it?įrom the man page: “git rebase: Forward-port local commits to the updated upstream head”. Rebasing, like most of git, should be learned and applied to be useful - not feared or misunderstood - so if you’ve been bitten by rebase in the past, or are simply curious about how it can be used, hopefully I can persuade you here of its utility. Feel free to share your own rebase experiences in the comments. Indeed, previously I worked on a team where the mere mention of a rebase to the wrong team member could evoke howls of anxiety and protest. ![]() We get superstitious sometimes, and in the face of the brain-crushing complexity of modern computing, who wouldn’t? One fear I’ve noticed is of git (in general) and in particular of git rebase. Developers like to pretend that we’re analytical and make decisions based purely on logic but the truth is that, like most people, we’re creatures of emotion and habit first and foremost.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |