'Will rebase main remove the current changes I made in my branch in git?
Basically I was working on my branch, made some changes to the existing files. I want to make a pull request. However, there has been some changes in main, so I think I probably need to rebase my branch with main first. In this case, if I rebase with main, will it delete my code changes in my own branch? Sorry maybe I sound ignorant but I am totally new to this. Please provide me with the workflow I need to follow so I can make sure my branch is up to date with the main branch without deleting any of my changes and make a pull request.
Solution 1:[1]
If you have not pushed any of your changes, then you can indeed rebase with git rebase main and you will not lose any of your changes; those changes will be "replayed" onto the latest commit of the main branch. If you have pushed any of your changes, however, you are better off doing a git merge main instead. The reason for this is that if you rebase commits that have already been pushed, you will get duplicates of those commits.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | David Deutsch |
