Fork other’s repository before cloning, because the code will not always run on your computer or other’s.
# 1. get the repository from your account that fork from other's
git clone https://github.com/<your-username>/<forked-repo>.git
cd <forked-repo>
# 2. Create a new branch.
git checkout -b <branch-name>
git remote -v
It will show repository you forked(origin) and the other’s repository(upstream)
origin git@version.aalto.fi:yans2/project.git (fetch)
origin git@version.aalto.fi:yans2/project.git (push)
upstream https://github.com/timbrist/project.git (fetch)
upstream https://github.com/timbrist/project.git (push)
git branch -r
It will show current branch(origin/main) you are using(origin/HEAD) and the branch of other’s repository(upstream/main)
origin/HEAD -> origin/main
origin/main # this is the branch you are using, HEAD is just a pointer(like c/c++).
upstream/main
case 1: Project “A” on GitLab, which import from Project “B” on GitHub, How to make a pull request when there is a update on Project “B”.
# 1. Clone your GitLab repository:
git clone <your-gitlab-repository-url>
cd <your-repo-name>
# 2. Add the GitHub repository as a remote:
git remote add upstream <github-repo-url>
# Fetch updates from the upstream repository:
git fetch upstream
# Merge updates into your local branch:
git checkout main # or whatever branch you are tracking
git merge upstream/main # or the appropriate branch
# ! Resolve Conflicts,
# I like to do it on vscode.
# Push Changes
git push origin main # or the appropriate branch