Author : MD TAREQ HASSAN | Updated : 2023/02/19
Overview
(A) Fork repository
- Go to the target repository url
- Click on “Fork”
- Create fork
(B) Clone repository
- Go to the remote repository URL (the repository you want to clone, it was foked from upstream repository)
- Copy SSH URL
- Clone the repository to your local using “
git clone
” command
(C) Add upstream repository to your local
We need to add upstream repository to our local (only once)
# Check upstream
git remote -v
# Add upstream repository to your local
git remote add upstream <upstream repository url>
(1) Make changes and commit
Make the changes you need in your local repository (i.e., modify, add, delete etc.):
Now commit using following commands:
git status
git add .
git status
git commit --message "<message here>"
git status
(2) Sync to upstream repository
Now sync using following commands (BTW, did you add upstream to your local? git remote -v
):
# get info: local <- upstream
git fetch upstream
# check that you are on the main branch
git branch
git checkout main
# merge: local <- upstream
git merge upstream/main
(3) Push to remote repository
After syncing to upstream, we need to push local changes to remote repository
git status
git pull
git push