How to GIT synchronize between origin and upstream branch

Nov 26, 2022
postimage

Git flow


This issue is because we want to update our local repository by merging the original sources. In this case, we use the “react-native-webrtc” package that forks from the repository.


In the first step, we create the new repository; in the example, I created the repo name with the prefix “custom” and then added the remote upstream, which refers to something that points to where it originated from.


git remote add upstream https://github.com/react-native-webrtc/react-native-webrtc.git
git fetch upstream
git checkout master
git merge upstream/master
git push origin
postimage

starting flow


Now that our branch has already updated from the upstream, let’s try to work on the basic workflow process. I start with the new branch and change the project name in package.json to a “custom-react-native-webrtc”. Following the image ref and cmd.


postimage

file has changed

  git checkout -b "feature/test-merge"
  git add .
  git commit -m "change repo name"
  git rebase origin/master feature/test-merge
  git push origin feature/test-merge --force-with-lease


HINT: At the end of this step, we should create the PR to merge into the master branch.


Conclusion

postimage

Compare the upstream repository and our new repository with our synchronizing.

Repository

My repo example:https://github.com/andreaharris-go/custom-react-native-webrtc