If you are collaborating with a team and working on a fork of a repo. Merge conflicts are common on git but you always need to be upto date to avoid nasty merge conflicts, which may very well kill your production time if you get too far behind. This is how you can download the latest update to your repo.
Getting Updates to Your PC to Compare With Your Local Version
- Add a remote that is pointing to the original repo. Skip this step if you already done this. Run
git remote add <remove_name> <remote_url>
- Fetch the remote
git fetch <remote_name>
. This will download the source repo to your pc. - Now that your source is downloaded you can compare it your local version with
git diff <remote_name>/<branch_name>
- Once you have checked there is not merge conflict you can now merge it to master.
Special Cases:
Their might be time you want to do one of the followings:
Discard all local changes and set master (or any branch) just same as remote repo:
Run the following after you fetch.
git reset --hard <remote_name>/<branch_name>
Leave a Reply