I studied to write Git before... I haven't used it often, but since I haven't used it in a long time, it doesn't work as I thought I forgot. Let me explain what the situation is...
Since it is a project that I am working on by myself, while I was working on A on the master branch without thinking, I found a bug that was urgent to fix in other parts, so I have to fix the bug first. Both actions have the task of modifying 'File A'. I wanted to leave the contents of work A behind and try to make a branch to proceed with work B first and distribute it.
Here's the scenario I thought of.
In this way, the working environment is separated for each branch, so I expected that I could edit 'File A' in an independent state every time I check out, but I don't think so.
How do branches and checkouts actually work? Also, what method should I use to edit the same file in different jobs at the same time as my situation?
git
checkout
is a command to move the head to the most recent commit of a particular branch. If there are files whose status has changed, such as unstaged, untracked file, or modified, move the head while maintaining the change point.
Therefore, to separate tasks by branch, you must save the current branch's work with stash
or commit
before moving the branch and then checkout
.
checkout
may fail in some cases. Typically, the branch you want to move and the change point of the current branch conflict, but you do not commit.
For an easy example:
© 2024 OneMinuteCode. All rights reserved.