Pull, Branch, Merge

Pull, Branch, Merge#

Pulling from Remote#

In case you are working together with others or you are working with multiple local copies of your repository it might be necessary to get changes from the remote instance:

git pull

In case you did some local changes that you want to discard cou can set you local repository to the latest remote version:

git reset --hard
git pull origin main

Branching#

Starting from the current version of your repository, you may want to implement and test two concurrent algorithms, e.g., method_a and method_b. Instead of copy-pasting your repository, you can use branches.

Create a new branch named my_new_branch:

git checkout -b my_new_branch

To get an overview of the branches in your repository, checkout:

git branch

If you want to switch to an existing branch, e.g., the main branch, type:

git checkout main

Merging#

After testing, you may want to implement the best of the two branches method_a and method_b back to your main branch. However, the main branch might have undergone changes since you branched from it, e.g., because your collaborators pushed their changes.

Working in teams and merging is a pretty advanced topic, which is covered, e.g. by the SURESOFT workshop series.