JavaPythonTech blog contains various tools and skills for a developer. Java/Python Best Practices, Tools, Examples, Programming interview questions.

How to switch branch in eclipse without losing workspace settings


You have checked out the required branch from git and would like to switch to a different branch using eclipse.

developer branch in the below example:

 

Now let’s make some changes to the existing file and add a file to depict workspace changes.





Now you would like to switch to another branch (developer2 in this example) without losing the changes done in your current workspace.

Select the Git perspective.

Right click on the git repository > Switch To > New Branch







In the “Create a new branch” window, click Select.





Select the branch you would like to switch to from “Remote Tracking”.

developer2 in the below example.



Check the “Configure upstream for push and pull” checkbox and select “Merge” from “When pulling” dropdown.

Uncheck the “Check out new branch” checkbox.

















Click Finish.



 
As you can see from the above image, we now have developer2 branch under Local.


All file changes and the new file are still intact and the branch has been switched to developer2 branch.

Note:
If you are not able to see the branches under “New Branch > Select”, please follow the below steps.

Go to Git perspective > Clone a Git repository

Enter the URL and credentials

In the “Branch Selection” window, select all the branches.


Click Next.


In the Local Destination selection window, select the required branch from “Initial branch” dropdown.

Click on Finish.

You will be able to see the selected initial branch under Local and all other branches under Remote Tracking.

 

Right Click on Working Tree > Import Projects > Finish.





Share:

1 comment:

Announcements

Will be posting twice a week on latest java libraries/frameworks which a developer needs to know in 2019.
Also will add the common errors and resolutions for the same.

Please feel free to comment if you need anything specific.

Recent Posts

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Contributors

Pages