I have seen this topic and this one but they don't quite fit my problem.
I have a remote repo with 3 branches (master, branch1, branch2) with many commits on each and I have also a local repo with some files and more recent work.
*I tried to -git init and add my remote to pull from branch1, clean the code then push. That was the idea to have a clean git project and a clean local repo. But it didn't worked. I had only my branch master and no possibility to switch to my branch "branch1".
*I tried also to -git clone my branch1 only. It worked. I got all the files with the last version from my branch1. But i had no .git and my branch1 was considered as my branch master.
*I tried to clone my entire project. But still, my branches do not appear with -git branch.
So I might need a little help to understand the proper way to do it. How do I sync my local repo (with more recent work) properly with my branch1 without losing or erasing my work ?
I also would like avoid conflits or cleaning a mess in the process.
Thank you all in advance for your help !
I found a solution to my current problem following this page but the downside was I had to use -git clone .
What I did not understand before was my remote branches could be found with -git branch -r
but I had to create a local branch to match the corrections I wanted to add to one of the remote branches.
So finally, what I did was :
-git clone <my_remote_repo>
-git fetch <my_remote_repo> <branch1>
-git checkout <branch1>
-git status
=> I erased the old files on my local repo , copied the new version in the same local repo , and then i used the usual
-git add <files>
-git commit -"m" <comment>
-git push <my_remote_repo> <branch1>
That might not have been the cleanest way, but it worked. If anyone have a more efficient way to do that, please don't hesitate to share.