I. Git tips
1. Add remote repository on a project and how to use it
It's common to fork a project to contribute on it. However, it can be problematic if you want your master branch (or any other) to be up-to-date since your fork won't update automatically. That's where remote urls get useful.
Nothing fancy or complicated in here. Once you have your remote url, just add it like this:
git remote add the_remote_name your_url
Of course, you need to replace "the_remote_name" by the name you want to give to the remote and "your_url" by the url of the remote repository. For example, I want to add a remote url on rust repository:
git remote add upstream https://github.com/rust-lang/rust
Now if I want to update my
master branch with the original rust repository:
git checkout master # to be sure we're on my local master branch git fetch upstream # we download the lastest changes on the original rust repository git rebase -i upstream/master # I update my local branch with "upstream" remote url and with its "master" branch
And we're all good. If you want to push changes to a remote repository:
git push some_remote_repository HEAD:the_branch_I_want_to_push_on
Please note that this is ALWAYS better to provide all information to the
git push command to avoid erroneous pushes.