changed 6 years ago
Linked with GitHub

HackyHour Potsdam 2019-01-16

When: January 16th, 2019 at 2:00pm CET
Where: Café Freundlich, Map
Info: Hacky Hour Potsdam Webseite

Recap & General discussion

Forking

On gitlab/github/ just klick on "fork" at the project wich you want to edit/change/contribute. If you have cloned the project before, thats no problem.

# clone your fork
git clone git@github.com:hafu/rdmo.git
# add the original remote (upstream)
git remote add upstream git@github.com:rdmorganiser/rdmo.git
# make your changes (preferd in a seperate branch)
...
# fetch (get) the changes from the original project
git fetch upstream
# checkout your branch, here we use the master
git checkout master
# merge the changes from upstream/master into your local branch master
git merge upstream/master
# push the changes to your remote repository
git push orign master

Cloned the original sources before making a fork? Just change the remotes:

$ git remote -v
origin  git@github.com:rdmorganiser/rdmo.git (fetch)
origin  git@github.com:rdmorganiser/rdmo.git (push)
# rename the remote
$ git remote rename origin upstream
$ git remote -v
upstream        git@github.com:rdmorganiser/rdmo.git (fetch)
upstream        git@github.com:rdmorganiser/rdmo.git (push)
# add your (forked) repository
$ git remote add origin git@github.com:hafu/rdmo.git
$ git remote -v
origin  git@github.com:hafu/rdmo.git (fetch)
origin  git@github.com:hafu/rdmo.git (push)
upstream        git@github.com:rdmorganiser/rdmo.git (fetch)
upstream        git@github.com:rdmorganiser/rdmo.git (push)

merge conflicts

Sometimes you have conflicts, if there are changes on both sides:

...
# fetch upstream and also tags (tags are used to "tag" a commit)
$ git fetch upstream
$ git fetch upstream --tags
# checkout my latest branch
$ git checkout 1.0.0-ffp
# create a new one from this
# at this point the branch 1.0.0-ffp and 1.0.1-ffp have the same content
$ git checkout -b 1.0.1-ffp
# merge the tag v1.0.1 (from upstream) in local branch 1.0.1-ffp
# at this point we have a merge conflict in file configs/common.config
$ git merge v1.0.1
Auto-merging configs/common.config
CONFLICT (content): Merge conflict in configs/common.config
Auto-merging README.md
Automatic merge failed; fix conflicts and then commit the result.
# open the conflicting file in an editor, you will find:
...
<<<<<<< HEAD
CONFIG_VERSION_NUMBER="1.0.0-ffp"
=======
CONFIG_VERSION_NUMBER="1.0.1"
>>>>>>> v1.0.1
...
# HEAD is your local repository
# change the conflicting lines and save the file(s)
...
CONFIG_VERSION_NUMBER="1.0.1-ffp"
...
# add the file(s)
$ git add configs/common.config
# finally commit your merge
$ git commit
$ git log -1 --oneline
9a74521 (HEAD -> 1.0.1-ffp) Merge tag 'v1.0.1' into 1.0.1-ffp

Participants

Select a repo