Git how to pull the update from original repository and keep my own changes

26 views Asked by At

should i clone-branch or fork-clone-branch.

the original repository is Tom's project in github, but i want to make some changes, and keep my changes while can keep updating or pulling update from original Tom's project.

can someone show me what is the right workflow?

thanks!

i tried to clone it and branch it

expecting to keep my own changes, but also can keep updating the original prject.

1

There are 1 answers

0
a4ary4n On

It would be easier to clone the repository and then create and work on your own branch.

git clone <repo>
git checkout -b <branch_name>

Commit your work on this branch and whenever you want to pull changes from the original repository, stash your changes (to avoid errors)

git stash

And then fetch and pull changes from the remote branch.

git fetch origin
git pull origin master

This way you can will be able to keep your changes, while getting the latest changes from origin.