So, I have a project where me and a colleague work both in the same script.
She already made some changes and uploaded to git. I have also done other things in the script and I now I would like to push also to the repository.
However, I am afraid the one of 2 things happen:
1- I pull her changes and I loose all my updates in the script.
2- I push my changes and I could get an error because the version is not the most recent one / or her changes are discarded.
What is the best way to deal with this type of co-working?
That scenario is why we have git.
Pull changes from repository
git will recognize that you’re merging changes and will show you which parts of code were changed
git will offer you options to accept incoming changes, keep your version of the code or decline incoming changes. it is up to you what you’ll do with every part.
you can continue working on script
commit it and push to repo for others to see your changes
they will go back to step 1 and repeat the process.
If you’re afraid your changes will disappear you can stash your changes or just copy your script to another folder until you’ll gain confidence in working with git.
Answered By – GregL