IskandarG IskandarG - 24 days ago 10
Git Question

Testing latest code on Git remote master branch before merging

I have a few commits already but someone pushed some changes on the master branch and I would like to play it safe by checking out and test the changes before merging it into my local master branch. How do I achieve this ?

Answer

you can fetch the remote branch which you can reference using FETCH_HEAD and then checkout that branch.

git fetch remote_branch

git checkout FETCH_HEAD

this will put you in detached state but if you just want to temporarily test these changes this is fine.

and after you are done testing you can merge back it to your branch.

git checkout your_prevous_branch

git merge FETCH_HEAD

Comments