7/27/2023 0 Comments Undo git stash applyNow if we do a git stash list, it's not in the stash anymore, so that's cleaned up, and we still have it in our code over here. We have to get rid of this stash manually if we want to do that. That's because, if there's a merge conflict, the code stays in the stash even if you do a pop, in case you mess up the merge conflict somehow. ![]() We did git stash pop, and it didn't come off. There's one last thing, which is, if we do a git stash list right now, we still see our stash. Now the changes are both locally and on GitHub. We have to add app.js, and then we can commit the "Hello from local" merged with GitHub. If we do a git status, we see that we have both branches modified app.js. Now we have both lines, "Alert from GitHub" and "Alert from local." We can save that. We are going to remove the merge conflict lines. You have to figure out what code you want to keep and what code you want to get rid of. The way to fix merge conflicts is just to manually go in and do it. Now when we're popping it off, we get the same thing that we would if we committed it, which is a merge conflict. What happened is like we committed this into the stash. Here, we have another problem, which is a merge conflict. Pop and apply are similar, but pop will remove the change from the stash and applies the change from the stash but keeps it in the stash as well, in case you want to use it later. The two ways we might do that are pop and apply. We can always do git -help stash to see how to get it back. Now we have to git our stashed changes back. Here is our "Hello from GitHub" that we added. If we do a git stash list, we can see our change was added over to the stash at zero. If we do git status, we can see we have no changes right here. If we do git stash, then it will take the code we just wrote and put it in a special stash. HEAD https ://Stashing Save the conflicted merge with git stash: git stash This step won’t work if there are unmerged paths. We're going to show how to stash them here. It says here our two options are to stash them or commit them. ![]() We have to do something to prevent our local changes from being overwritten for now. What we get is that our local changes will be overwritten by the merge. Let's go back to our code here, then, and try a git pull. Now our app.js on GitHub says "Hi from GitHub." I can say, "Hi from GitHub change." I will commit directly to the JS changes branch. ![]() Hi from GitHub." Down here, I can commit that change. We can actually edit it right here on GitHub. This is the last version that was pushed. What happens if someone else changes that file? If we go over to GitHub here and go to our JS changes branch, we can check out the app.js file. Now if I do a git status, I have unstaged changes. I want to change my "Hello, world" function to say, "Alert. Instructor: We are in a feature branch here called JS changes.
0 Comments
Leave a Reply. |