Branches are simply pointers to a commit. We don’t have to move any commits to a branch: instead we move the labels around. The critical point to this operation - the reason this is really easy for me now, but was super-hard before I understood the commit graph - is that we don’t have to move any code. If a commit is reachable in the history from any reference (branch, HEAD, tag), then it is safe. Git will always and forever remember the exact state of your code at any commit that has a label, or is in the history of any commit with a label. Why is “–hard” not dangerous? well, it can be. “–hard” tells git to rejigger all your files. This is the third thing that your git reset command did, thanks to “–hard”: it replaced everything in your working directory with what the repository looks like in origin’s master branch. That new_feature branch is sticking out up there, saving your work. Nothing to commit (working directory clean)Īnd in gitx (if you’re on a Mac, please download gitx): # Your branch is ahead of 'origin/master' by 2 commits. git status looks like: # On branch master The detailsġ) After your changes are committed, you’re still on the master branch. It’s ok if they’re not finished you’ll come back to these later.īam, your changes are saved off on feature_branch_name, your current working directory matches what was in the origin repo last time you fetched (or pulled) from it, and you are ready to start work on the bug. Then, I’ll tell you how it works, so that you can adjust the solutions to your own needs. Now you need to work on a bug instead, so you’ve got to put these changes away - if only you had branched! You wish you had started a branch for this feature, back before you began it. Say you’re working along on a branch (let’s say master), and suddenly you realize that this task is harder than you thought.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |