So I am signed in github and I fork a project . Will my forked repo get updated everytime the original repo updates ? Or should I do forking from the original repo everytime so
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
No your fork won't be updated automatically everytime and you can't fork a repository more than once. If you want, you'll have to delete the prev fork and refork the repo.
To keep your fork updated with original one you can follow below steps:
first add the original repo as a remote upstream in your local forked one:
git remote add upstream [upstream.git]
Now, you can easily syncronize your forked (origin) repository with the upstream one by doing
git checkout master # Make sure you always run the following commands from the master branch
git fetch --all
git pull --rebase upstream master
git push origin master
This will rebase
the upstream changes on your local forked version so the master
branch git history will look exactly the same at the end.
to pull from the original repo use:
git pull upstream master # you will get the original repo's update
and to pull from the forked one:
git pull origin master
Will my forked repo get updated everytime the original repo updates
No. Fetching from the original repo from time to time is completely up to you. You can easily do it at your local repo (by convention, the original remote is called upstream
while the fork remote is called origin
).
When you want to get updates from the original version and merge these with your version, you can use the git pull command. More info is on this here: https://docs.github.com/en/free-pro-team@latest/github/getting-started-with-github/github-glossary#pull
If you choose to fork a repository it copies this repository to your profile. It is essentially the same as cloning but with a fork, a connection between your 'forked' version and the original version is maintained (for pull requests).
This is a very quick and simple description. There is more info here: https://github.community/t/the-difference-between-forking-and-cloning-a-repository/10189