[Git] Git Fork

less than 1 minute read

Git Fork

  • Git Fork Workflow
  • Git Fork Workflow Demonstration

Git Fork Workflow

  • Git Fork allows a project amintainer to accept contributions without having to add them as actual owners/collaborators of the main project repository
  • Git Workflow (as a collaborator)
    • 1) Fork the project
    • 2) Clone the fork (to local repository)
    • 3) Add upstream remote
      • for getting recent updates from the original repository
    • 4) Make commits
    • 5) Push to Origin(forked)
    • 6) Open a PR (to upstream)

Git Fork Workflow Demonstration

# 1) fork the project
# 2) clone the fork(git clone {forked-repo})
git clone forked-repo-example

# check the remote
git remote -v

# 3) add upstream remote (git remote add upstream {https://{git_repo.com}/{owner}/forked-repo.git})
git remote add upstream https://github.com/zsu58/forked-repo-exampe.git

# check the remote again, and see whether upstream is added
git remote -v

# get recent updates from upstream(git pull {remote_branch} {branch_name})
git pull upstream main

# 4) add commits

# 5) push to origin(forked repository, (git push {remote_branch} {branch_name}))
git push origin main

# 6) open a PR

Tags:

Categories:

Updated: