Below is the local repo structure :
developement master
A A
B<--------------B
C (pushed to
D remote/master)
E
F
G
H
(pushed to
remote/developement)
I want to make it like below on local as well as master.
developement master
A A
B B
C-------------->C
D-------------->D
E-------------->E
F-------------->F
G-------------->G
H-------------->H
want to discard development branch after merging it to master branch at local repo.
Thank you!
CodePudding user response:
I am not sure if you have two remote branches, with the solution below I
imagine you having changes on one local branch "non-master" and you want these changes on master.
If this answer does not meet your needs, please leave a comment here and I will be able to edit my solution to fit your needs.
Note, during merging, you may run into merge conflicts, pick the new changes from the new local branch
step 1
Make sure all changes on your non master branch are committed locally before you checkout to the master.
You can do that by running this command
git add .
git commit -m "saved changes on the local branch to be merged into master"
Now checkout the master branch so that you can introduce new changes
git checkout master
git merge non-master
git add .
git commit -m "merged non-master into master"
git push
If you want to delete the local branch
git branch -d non-master
If you want to delete the remote branch
git push origin --delete name-of-remote-branch
Incase you have a second remote branch for example development, checkout on the local version of development, rebase development on master and push the changes to remote development.
Those steps would like like this below
git checkout development
git rebase master
If you have merge conflicts and you don't remember what piece of code needs to stay or go, abort the rebase and instead do a merge
git rebase --abort
git merge master
If one of the two has worked for you, push the changes to your remote origin now all should be well good. Solution did not work?, get back to me I will be able to help.