Last week I created a branch for a feature and merged it locally with master. I did have some issues but everything worked. I merged another branch with my final feature and merged locally to master again but I had some issues. I don’t even know where to begin. I need to know how to get my final version which is on my hamburger-menu branch into my master branch.
My repo is Tarp Configurations. My commit from yesterday was from master before I created my new branch. I had some issues with files in the master branch, I had to fix them but could not switch back to my branch until I committed them - I also pushed them. Basically, I need the changes from my branch to merge into my master but I have a few commits in the way. I did a git revert for my last commit from master but I need to do that I think 3 or 4 more times.
It looks like you have the hamburger-menu branch pushed up to GitHub. Can you just make a Pull Request (hamburger-menu→master (edit: or maybe the other way around? I’m still not 100% sure on what your issue is)) and try to resolve conflicts there if any come up?
I’m not sure if I’m competent enough to explain what is going on. I guess my branch got pushed after I merged it locally with Master. But I was getting errors - merge conflicts where you get the ====HEAD and >>>> things throughout the file. Here is one of the stupid things I did - I copied the 3 files that had problems while in my branch into a separate project folder. Then I used that code for the corresponding files in Master. But now Master is messed up - my menu changed, my hamburger button doesn’t work, …
Here is what I had in my console (sorry about the F-bombs in my commit messages):
$ git reflog
e40ac45 (HEAD -> master, origin/master) HEAD@{0}: revert: Revert "FUCK"
a52caa8 HEAD@{1}: checkout: moving from hamburger-menu to master
20ce407 (origin/hamburger-menu, hamburger-menu) HEAD@{2}: checkout: moving from master to hamburger-menu
a52caa8 HEAD@{3}: commit: FUCK
a1af2bd HEAD@{4}: checkout: moving from hamburger-menu to master
20ce407 (origin/hamburger-menu, hamburger-menu) HEAD@{5}: checkout: moving from master to hamburger-menu
a1af2bd HEAD@{6}: commit: Fucking local merge
fb522e7 HEAD@{7}: checkout: moving from hamburger-menu to master
20ce407 (origin/hamburger-menu, hamburger-menu) HEAD@{8}: checkout: moving from master to hamburger-menu
fb522e7 HEAD@{9}: commit (merge): Ready to push to Netlify
ef73039 HEAD@{10}: checkout: moving from hamburger-menu to master
20ce407 (origin/hamburger-menu, hamburger-menu) HEAD@{11}: commit: Finished hamburger menu
git log --oneline --graph --all
$ git log --oneline --graph --all
* e40ac45 (HEAD -> master, origin/master) Revert "FUCK"
* a52caa8 FUCK
* a1af2bd Fucking local merge
* fb522e7 Ready to push to Netlify
|\
| * 20ce407 (origin/hamburger-menu, hamburger-menu) Finished hamburger menu
* | ef73039 push before hamburger menu build
* e40ac45 (HEAD -> master, origin/master) Revert "FUCK"
* a52caa8 FUCK
* a1af2bd Fucking local merge
* fb522e7 Ready to push to Netlify
|\
| * 20ce407 (origin/hamburger-menu, hamburger-menu) Finished hamburger menu
* | ef73039 push before hamburger menu build
I tried git pull from master, I did a reset for my last commit. I don’t know what to do. Branch hamburger menu is what I want. How to I get that?
No the reverse. My master was pushed yesterday before I created hamburger-icon. I finished that tonight and did git checkout master followed by git merge hamburger-icon. I would prefer that hamburger-icon branch was master but everything is messed up now. I had to do git add filename for a few files back in master after the merge. I got the merge conflict things …blah-blah-blah. I’m considering running npx create-react-app tarp-project --use-npm again but for a new project folder and then moving everything over somehow.
Can I somehow clone my branch hamburger-menu into a new project folder on my laptop and treat that as my “master” branch in that new folder? Then push that to a new repo on GitHub?
I downloaded that branch, copied it into a new project folder, and am running npm install now but it’s taking FOREVER. Assuming it finishes soon, I’ll run npm start to make sure it’s where I left off, and then I’ll use that new project folder as my project. create-react-app runs quicker so I’m wondering what is causing the slow install.
… just finished…will give updates in a minute. BTW, is merging a branch locally a bad idea? If so, where are the docs for basic/beginner git commands?
Hmm, that is hard to say. My finished version before working on the mobile menu was yesterday right before I created the hamburger-menu branch. I don’t know why merging that branch into master created issues, but I will never merge locally again. I ran npm start but I forgot I did not have my assets folder. Had to stop and restart. I messed up but I do not know what I did wrong - that is what really bothers me. It’s weird how my cloned branch moved into a new folder has a branch name of main. It’s late and I’m going for the brute approach - create a new repo, delete the old. Why does local merges create a problem? Or am I missing something?
Bingo! It worked but it’s a hack solution that works for a self-taught newbie. I thank you and collin for chiming in. I would like to somehow figure out what I did wrong.
Wait a minute. FYI, I’m beat and calling it a night. Why would I have to pull anything down if I am creating a new branch after pushing all changes up? Is there something “weird” with local merges that you need to do a git pull after creating the branch, even though the newly created local branch should be a copy of master? Argh! I should have this on Netlify and updating my portfolio, instead I emptied the fridge of cold beers and will pick up in the morning…