Steps to Recover Lost Changes Process of Upstream Rebase
By following the below steps you can recover the changes you lost in the process of Upstream Rebase.
Step 1: First, go through the local repository for missing commits reflog. The reflog keeps track of all repository modifications, such as branch updates, merges, and rebase. Run the git reflog command to see the reflog. Find the commit IDs for the lost changes you made and copy the most recent one.
Step 2: Create a new branch by using the commit Id you recovered which is lost by using the below command.
git branch <new branch name> <commit id>
Step 3: After creating the new branch by using cherry-pick command you can recover the changes that were lost in the upstream rebase. For this use the below command.
cherry pick <commit id>
Step 4: While using the cherry-pick command you may face lots of conflicts and problems that need to be resolved. After resolving the conflicts use the below command and stage the files.
git add <file>
Step 5: The last and final step after completion of all the above steps by resolving all the errors, know to push the branch that has been created newly to the remote repository by using the below command.
git push -u origin <new branch name>.
After completion of all the above steps, we can check our remote repository like (GitHub) whether the new branch is pushed with all the lost changes or not.
Git Rebase
Pre-requisites: Git
Git rebase can integrate the changes from one branch to another by overcoming the problems that we might have faced while using the git merge command. The changes we will do will be recorded in the form of logs which are useful to go through if any mistakes happen.