How to work with Fork of a project?

Asked

Viewed 1,179 times

1

I made the Fork of a project, made the appropriate changes, pushed to my repository on Github and there generated a pull request to the original project’s Object.

After a few days I decided to make a new contribution, however, the original repository has already undergone several updates. What should I do?

I thought: add the remote of the original repository and do a pull, is that correct? I even did a test but it doesn’t seem to have pulled the latest content.

Would that be it?

  • Utilize git pull

  • Add the remote and run git pull?

  • If you are using git clone <repositório> to clone a repository, you do not need to add additional information, except if you have other repositories. At http://rogerdudler.github.io/git-guide/index.pt_BR.html you have some tips that can help.

1 answer

2

In your local clone of your repository Fork, you can add the original Github repository as remote. remotes are like aliases for repository Urls - for example, origin is one of them. So you can use git fetch to bring all the branches of that repository on upstream, and git rebase to continue working on your version. The command sequence would look something like this:

# Adiciona o remote, chamando-o de "upstream":

git remote add upstream https://github.com/usuario/projeto.git

# Traz todas as branches daquele remote para remote-tracking branches,
# como por exemplo upstream/master:

git fetch upstream

# Garantindo que você esta na branch master:

git checkout master

# Rescreve sua master branch para que quaisquer commits seus que
# ainda não estão na upstream/master sejam replicados no topo daquela
# outra branch

git rebase upstream/master

If you "rebaseou" your branch for upstream/master maybe you need to force the push so that you can give the push to its own repository Fork on Github.

git push -f #irá forçar o push

References

  1. How do I update a Github forked Repository?
  2. How to Github: Fork, branch, track, squash and pull request
  3. How git rebase works?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.