This is a question I have been meaning to ask for a while. I first noticed this confusing problem about a year ago and never managed to find a solution.
I am completely dumbfounded by divergent branches.
I just started a new repository.
Here's what I've done:
- Create a repository on my local gitlab server (using the web UI)
- Clone this repository to my desktop machine (where I do the majority of my typing of code)
- Clone this repository to my server (in this case just a Raspberry Pi)
- Add some initial code to the Raspberry Pi filesystem.
git add <some stuff>
git commit ... -m blaa
git push
- Do a
git pull
on the desktop machine
To clarify there are 3 machines:
- A local server which runs an instance of gitlab
- A local production server (R-Pi) which runs the code I have written
- A desktop machine where I write most of the code
A warning pops up. Here's what it says:
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 516 bytes | 516.00 KiB/s, done.
From [URL]:[NAME]/[REPO]
* [new branch] master -> origin/master
I am completely confused. Previously I have seen these warnings after working on some project for a much longer period of time.
All I am trying to do is keep a central server location up to date with a backup of my code, and then mainain another 2 copies of that on 2 local machines.
Most of the time I want to do most of the changes on my desktop machine, push these to the central server, and then pull the changes down to the production server.
Occasionally, I mess something up (miss-spell a variable etc), and want to be able to correct that on the production server over ssh before running the code.
After doing any small corrections, I want to be able to push changes back to the central repository, and pull them down to my desktop machine.
I must be doing something completely wrong if I am recieving this warning this early on during development.
What is my mistake? What am I doing wrong? What causes this warning? I don't understand what it actually means in terms of the files and code I am maintaining on my system(s).
Further to this: Three options are recommended. The typical answer is "pick one command, run it and be done with it". However I don't understand what these options do.
The three options are
- Set "rebase" to false
- Set "rebase" to true
- Set "ff only"
What do these options mean? What do they do? Finally, what is the "default" behaviour? The pull
completed successfully, as the pull
ed code is now on my system.