![]() You can resolve the conflict by comparing the two lines and choosing which change you want to keep. You’ll then have to resolve the conflict by opening the file with your usual editor: > fundingPotImprovement Git will see that you’re trying to merge two different things on the same line, but it won’t know which to use between “A funding pot” and “A great funding pot!” It’s clever, but not telepathic! Therefore, Git will show a conflict in the file FundingPot.php and stop the merge process. You’ve changed the code to show the message “A great funding pot!”-except that there was already another message in place: “A funding pot.” This makes for a tricky situation when you try to merge the two branches: git checkout mainĪuto-merging FundingPot.php CONFLICT (content): merge conflict in FundingPot.phpĪutomatic merge failed fix conflicts and then commit the result Going back to the example from the beginning of the course, let’s say you’ve been working on a branch called “fundingPotImprovement.” However, there are already files corresponding to improvements made to the Funding Pot feature on the main branch, and you’re changing lines that are already in place. Unfortunately, sometimes (actually quite often), things don’t work out so well, and you end up with conflicts. In the second part of this course, you saw how to merge branches, using a simple example where everything worked as it should. It doesn’t delete any files or commits, nor does it create a detached HEAD. With this command, you can go to a specific commit to see the code at a given moment or create a branch based on an old commit. It’s a bit like your shadow-it follows you wherever you go! By default, HEAD points to the current branch, main/master, but can be moved to another branch or another commit.įinally, there’s git reset -soft. HEAD is a pointer-a reference to your current position in your Git working directory. ![]() ![]() If nothing is specified after git reset, a git reset -mixed HEAD~ will be launched by default. You can also use it to unstage files for files that have been staged but not yet committed. The command git reset -mixed allows you to go back to where you were just before your last commit, or any specific commit, without deleting the changes you’re working on. ![]() This command is incredibly useful when you’ve started working on a feature, made a mistake, and want to start again from scratch. Using git reset is a simple way of canceling changes that haven’t yet been shared. This command can take you back to any commit you want but wipes absolutely everything done after it! When I say everything, I mean EVERYTHING! Any changes or other commits made afterward will all be deleted! This is why it’s crucial to check several times before launching it, as you could lose all your changes if you get it wrong. Run the command: git reset OurTargetCommit -hard If you want to run this command, check at least five times before you launch it, and make sure you’re 200% sure of yourself! It can be used in three different ways, which correspond to the command line arguments -soft, -mixed and -hard. The command git reset is a complex and multifunctional tool to undo changes. You’ve wasted two days developing a feature for nothing, and what’s more, you now have to find a way of going back to where you were before! Luckily, our friend Git comes to the rescue with the command git reset ! Go back to where you were using git reset The Three Types of Git Reset You work on it solidly for two days, and he changes his mind in the end. ![]() Imagine this: your client asks you for a new feature. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |