How to work with fork of a project?

1

I made the fork of a project, made the changes, made the push to my repository in Github and there I generated a pull request for the repo of the original project.

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 about: adding the remote from the original repository and doing a pull, is this correct? I did get tested but it does not seem to have pulled the latest content.

Would that be it?

    
asked by anonymous 12.03.2018 / 19:04

1 answer

2

In your local clone of your repository, fork , you can add the original GitHub repository as remote . remote s are like nicknames for the URLs of the repositories - for example, origin is one of them. So you can use git fetch to bring all the branches of that repository into < in> upstream , and git rebase to continue working on your version. The sequence of commands 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 "overflowed" your branch to upstream/master you might need to force push to get the push to its own repository that was made fork in GitHub.

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

References

  • How do I update a GitHub forked repository?
  • How to GitHub: fork, branch, track, squash and pull request
  • How does git rebase work?
  •     
    12.03.2018 / 20:14