1. Forking & Upstream Synchronization
git clone <fork-url>What it doesCopies the fork repository from your account to your local machine
When to use itAfter forking any project on GitHub and starting to set it up locally
Example
git clone git@github.com:YOUR_USERNAME/PROJECT.gitgit remote add upstream <url>What it doesAdds the link to the original repository of the project as upstream for reference
When to use itto synchronize changes coming from the original project in the future
Example
git remote add upstream https://github.com/ORIGINAL_OWNER/PROJECT.gitgit fetch upstreamWhat it doesFetches all new branches and commits from the original repository without merging them
When to use itBefore starting a new job or before synchronizing the master branch
Example
git fetch upstreamgit merge --ff-only upstream/mainWhat it doesAdvance the local branch pointer to the most recent commit in the original repository without creating a commit merge
When to use itto update the local main branch to exactly match the original repository
Example
git merge --ff-only upstream/maingit push origin mainWhat it doesUploads updates taken from the upstream to your fork repository on GitHub
When to use itto keep the master branch in your cloud copy in sync with the original
Example
git push origin maingit push origin feature-branchWhat it doesThe new modifications branch is uploaded to the fork in preparation for opening PR to the original project
When to use itAfter you finish preparing a feature or fix to contribute
Example
git push -u origin feature-fix-type