• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GIT related issues
#31
(07-06-2016, 11:59 AM)wo_rasp Wrote: Just checkout the various commits and have a look at the version you want to keep, most probably commit 9cdc7c1 is the one you want to recover.

simply try: git checkout 9cdc7c1.

If the files are all intact, you will get the message, that you are in "detached head", that means there is no branch name associated with this commit.

GIT is telling you what to do to assign the branch name, just do it, and you have recovered your version.
Thanks again. Indeed after "git checkout 9cdc7c1" git told me "detached head"!

So far so good!

If I now execute "git branch" I see the following:
Code:
~/pilight# git branch
* (no branch)
 GPSprotocol
 development

~/pilight#

Still no worries, but what does GPSprotocol point to? I cannot "git checkout -b GPSprotocol" because GPSprotocol already exists..

Code:
~/pilight# git checkout -b GPSprotocol
fatal: A branch named 'GPSprotocol' already exists.
~/pilight#

So did the following:

Code:
~/pilight# git branch -m GPSprotocol GPSoldname
~/pilight# git branch
* (no branch)
 GPSoldname
 development

~/pilight# git checkout -b GPSprotocol
Switched to a new branch 'GPSprotocol'

~/pilight# git branch
 GPSoldname
* GPSprotocol
 development

~/pilight# git log --oneline --decorate --graph --all
*   9cdc7c1 (HEAD, origin/GPSprotocol, GPSprotocol) implementation of the General Purpose Sensor protocol https://f
|\  
| *   d2b181e (upstream/development, origin/development, development) Merge pull request #287 from mrWheel/developm
| |\  
* | | 55df041 (GPSoldname) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-P
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \  
| |/ /  
|/| /  
| |/    
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supp
|/  
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\  
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?p
|/  
*

Looks good!

Code:
~/pilight# git branch -d GPSoldname
Deleted branch GPSoldname (was 55df041).

~/pilight#

.. and then:

Code:
~/pilight# git push origin GPSprotocol -f
Everything up-to-date

~/pilight#

So, just did a PR to the development branch of pilight (previously I did not pay attention and PR'ed to the master!Tired)

I hope all is well now and many thanks. Again.

Reagards
 
Reply
#32
Use
Code:
git checkout GPSprotocol
to change to the GPSprotocol branch. The "-b" option is needed to create a new branch object, but once it exists, you can just use "git checkout" to switch to it.
 
Reply
#33
Correct, however in this case the HEAD of branch GPSprotocol was pointing to a commit, that was not populated with the most recent changes, as a "git pull" command was issued and the most recent changes were replaced, and the sha code of the most recent commit was removed and the branchname GPSprotocol was no longer pointing to the commit with the most recent changes.

USERS coming from other version control systems are used to understand that a branch presents a set of archived/saved files saved on a central repository in a directory tree.

As long as USERS do one commit after another and work with one branch only, it looks pretty much the same within GIT, but this is not how GIT stores the data in its repository. In particular a branchname is only a pointer to a specific commit and this pointer can be moved around.

GIT is saving changesets, and uses a sha code to access the saved information. The command "git diff commit-sha1 commit-sha2" will report the differences between two commits.

When you checkout a commit the content of the index (stageing area) and work area is the same. When you edit a file in the workarea, "git diff" will tell you the differences.

When you do a "git pull" GIT incorporates the changes from another repository on top of the current commit, by reapplying them. If you are unsure on what will be applied, is is recommended to use "git diff" and check what GIT will do. In our case here the newest changes were removed unintentionally.

"git pull origin rep-name" is a combination of "git fetch origin rep-name" and "git merge origin/rep-name".

As a summary, try to stay away from "git pull", in particular, whenever GIT complains about user actions, but use "git fetch", check with "git diff" what GIT will do and do the merge afterwards.
 
Reply
#34
@wo_rasp,

Will you please take a look at the pull request for "GPSprotocol" in github?

If I read it right it seems there are 3 commits where, according to all the instructions you gave me, I would expect only one..
 
Reply
#35
Well, I think the 1st step was to recover your work, and I assume that the sequence of your commits is now appropriate for that.

The 2nd step is now, if desired, to squash all commits into one and to fix some other issues.

I think you still are using GIT on the base understanding of saving snapshots in branches.
Your mind is set based on your mindset.
Before you continue, try to change your mindset:

1. Do not think about GIT saving snapshots, but about GIT saving changesets, e.q. GIT is handling the differences between two commits GIT has powerfull features to automatically replay the changes made.
2. With git rebase you can combine multiple commits (changesets) into one, you also can use it to re-order the sequence of changesets, or to delete one or multiple changesets.
The problem you will always face while working with changesets are the merge conflicts, so in the future your goal is to keep an eye on "how do I avoid merge conflicts". There are more powerfull commands built into GIT but once you have mastered this understanding you will always find your way around.

With regard to Step 1:
Looking at your "ref-log" i came to the conclusion that (9cdc7c1) is the sha-code with the most recent changes, (55df041) is a previous commit.

To squash all log entries into a single commit, the easiest thing to do is a rebase.

Before we do this, it is important to understand what the machine will do and to ensure that the programmer will agree.
The first thing to do is to look for a common root.

"git log --all --oneline --graph --decorate" reveals:
Code:
*   9cdc7c1 (HEAD, origin/GPSprotocol, GPSprotocol) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
|\
| *   d2b181e (origin/development, development) Merge pull request #287 from mrWheel/development
| |\
* | | 55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \
| |/ /
|/| /
| |/
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional

I look for the commits identifying your development branch, and your GPSprotocol branch.

We have here an interessting issue, that highlights a major problem, that in this case only affects you, but if it happens in a more complex environment (e.q. multiple developers and multiple local repositories) will cause even more problems.

Code:
1. (a2719cf) was created on Jun-13th and is the common root commit for your development branch and your GPSprotocol branch.

2. With (08e140e) work was added to the development branch on Jun-15th and a PR was issued on Jun-20th to integrate that work into the pilight development branch.

3. With (d2b181e) the maintainer of the pilight project (curlymo) accepted that PR on Jun-26th.

4. With (d2b181e) the PR was pulled back into your development branch and than into your GPSprotocol branch. The ref-log from your local repository confirms this:
- d2b181e HEAD@{14}: merge upstream/development: Fast-forward
- a2719cf HEAD@{15}: checkout: moving from development to GPSprotocol
- d2b181e HEAD@{16}: merge upstream/development: Fast-forward
- 08e140e HEAD@{17}: checkout: moving from GPSprotocol to development

The answer to my question, "Why did you pull this commit (d2b181e) into both of your branches ?" is most probably:
Code:
- You wanted to have that changeset integrated into your GPSprotocol branch as well.
This is why you can see on your (mrwheel) github account, that "curlymoo committed with MrWheel on Jul-2nd" for commit (09296d2).
 
Well you can do that but it can get you (and others) into real trouble and you may have to pay a high price for it (you may end up in merge conflicts, missing commits at a later stage, etc). And as you will learn in a minuite GIT will complain, and if you are not careful, you will loose work.

In short: You should keep (09296d2), in case someone else branches of from that commit.

Based on what I said before

Code:
1. I hope that all readers have shifted there mind from snapshot to changeset.
2. In the future changes in the development branch are kept to the development branch.
3. If changes from the development branch shall be added to your GPSprotocol branch, the anchestor root of GPSprotocol should be moved.

In this case:
The root commit of the GPSprotocol branch should be moved from (a2719cf) to (d2b181e) and not merged (08e140e) into multiple branches. It is easy to use "git rebase" to move your GPSprotocol root, once it is understood how "git rebase" is acting. There is another thread in this forum discussing that subject.

If you are unsure what to do, simply create a new directory and push your work to a dummy github repository.

In the example below I am using as directory "willem_4" and I have setup on my own github account a bare repository called dummy.

Step 1: Get your complete repository and clone it to my PI:
Code:
root@pi_65:/home/pi# mkdir willem_4
root@pi_65:/home/pi# cd willem_4
root@pi_65:/home/pi/willem_4# git clone https://github.com/mrwheel/pilight.git
Klone nach 'pilight'...
remote: Counting objects: 15401, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 15401 (delta 1), reused 1 (delta 1), pack-reused 15398
Empfange Objekte: 100% (15401/15401), 10.95 MiB | 724.00 KiB/s, Fertig.
Löse Unterschiede auf: 100% (11821/11821), Fertig.
Prüfe Konnektivität... Fertig.

Now i am attempting to get an overview, as expected we are on the "master" branch. I now change to the "development" branch (only for the purpose of showing how the output of the "git log" command looks like) and finally I checkout the "GPSprotocol" branch:
Code:
root@pi_65:/home/pi/willem_4# cd pilight/
root@pi_65:/home/pi/willem_4/pilight# git log --oneline --graph --decorate -n10
* 24e7387 (HEAD, tag: v7.0, origin/master, origin/HEAD, master) pilight version 7.0
* fa3139d Fixed teknihall protocol
* 3352845 Don't log pre-hashed password
* f566d33 Small fix in rsl366
* 7eba188 Allow new loglevel maximum
* 8607de9 Updated default config with updated settings
* cdcf4a1 Add newline to stderr message
* e81e790 Error check some mallocs
* eb60f80 Remove ntp-sync setting and just use ntp-servers
* caefc18 Rechecked log messages
root@pi_65:/home/pi/willem_4/pilight# git checkout development
Branch development konfiguriert zum Folgen von Remote-Branch development von origin.
Zu neuem Branch 'development' gewechselt
root@pi_65:/home/pi/willem_4/pilight# git log --oneline --graph --decorate -n10
*   d2b181e (HEAD, origin/development, development) Merge pull request #287 from mrWheel/development
|\
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?pid=18378#pid18378
|/
*   62e3f56 Merge pull request #284 from dominikkarall/development
|\
| * 1476cb1 change short pulse to 500
* |   a42a65e Merge pull request #283 from wo-rasp/tcm
|\ \
| * | 09d189b Bugfixing tcm protocol: structure tfa-> chenged to tcm-> for both battery objects
| |/
* |   ae2d5c4 Merge pull request #272 from dominikkarall/development
|\ \
| |/
|/|
| * 8bad6c7 use 3rd bit for hash map selection
|/
root@pi_65:/home/pi/willem_4/pilight# git checkout GPSprotocol
Branch GPSprotocol konfiguriert zum Folgen von Remote-Branch GPSprotocol von origin.
Zu neuem Branch 'GPSprotocol' gewechselt
root@pi_65:/home/pi/willem_4/pilight# git log --oneline --graph --decorate -n10
*   9cdc7c1 (HEAD, origin/GPSprotocol, GPSprotocol) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
|\
| *   d2b181e (origin/development, development) Merge pull request #287 from mrWheel/development
| |\
* | | 55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \
| |/ /
|/| /
| |/
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?pid=18378#pid18378
|/
*   62e3f56 Merge pull request #284 from dominikkarall/development
|\
| * 1476cb1 change short pulse to 500
* |   a42a65e Merge pull request #283 from wo-rasp/tcm
|\ \

GIT is pretty user friendly, if I want to rebase my current "GPSprotocol" on the tip of the "development" I can do so now, as "git log" has not revealed any major issues (forks/merges of other branches that may concern me):
Code:
root@pi_65:/home/pi/willem_4/pilight# git checkout GPSprotocol
Bereits auf 'GPSprotocol'
root@pi_65:/home/pi/willem_4/pilight# git rebase development
First, rewinding head to replay your work on top of it...
Applying: implementation of the General Purpose Sensor protocol
Using index info to reconstruct a base tree...
A       libs/pilight/protocols/433.92/gpsensor.c
A       libs/pilight/protocols/433.92/gpsensor.h
<stdin>:34: trailing whitespace.
        Copyright (C) 2014 CurlyMo & TheWheel
<stdin>:45: trailing whitespace.
        Copyright (C) 2013 CurlyMo & TheWheel
warning: 2 Zeilen fügen Whitespace-Fehler hinzu.
Falling back to patching base and 3-way merge...
KONFLIKT (ändern/löschen): libs/pilight/protocols/433.92/gpsensor.c gelöscht in HEAD und geändert in implementation of the General Purpose Sensor protocol. Stand implementation of the General Purpose Sensor protocol von libs/pilight/protocols/433.92/gpsensor.c wurde im Arbeitsbereich gelassen.
automatischer Merge von libs/pilight/protocols/433.92/alecto_ws1700.h
KONFLIKT (Inhalt): Merge-Konflikt in libs/pilight/protocols/433.92/alecto_ws1700.h
Failed to merge in the changes.
Patch failed at 0001 implementation of the General Purpose Sensor protocol
The copy of the patch that failed is found in:
   /home/pi/willem_4/pilight/.git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

Okay, so GIT is nice to us, and keeps the copy of gpsensor.c in the workspace area.
GIT also has detected that there is a conflict in the headerfile alecto_ws1700.h 
Thus we inspect those files first and look for conflicts. Befor we continue we have to agree with the changes made/suggested by the machine.

Code:
root@pi_65:/home/pi/willem_4/pilight# nano libs/pilight/protocols/433.92/gpsensor.c
root@pi_65:/home/pi/willem_4/pilight# nano libs/pilight/protocols/433.92/alecto_ws1700.h

1. I am assuming that using the working copy of gpsensor.c is okay.
2. In alecto_ws18700.h i resolved the merge conflict in the comment line and saved the result.
If we continue now with "git rebase --continue", GIT will remind us that there is still some confirmation required:
Code:
root@pi_65:/home/pi/willem_4/pilight# git rebase --continue
libs/pilight/protocols/433.92/alecto_ws1700.h: needs merge
libs/pilight/protocols/433.92/gpsensor.c: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

So we use "git status" to get an overview:
Code:
root@pi_65:/home/pi/willem_4/pilight# git status
Rebase im Gange; auf d2b181e
Sie sind gerade beim Rebase von Branch 'GPSprotocol' auf 'd2b181e'.
  (beheben Sie die Konflikte und führen Sie dann "git rebase --continue" aus)
  (benutzen Sie "git rebase --skip", um diesen Patch auszulassen)
  (benutzen Sie "git rebase --abort", um den ursprünglichen Branch auszuchecken)

zum Commit vorgemerkte Änderungen:
  (benutzen Sie "git reset HEAD <Datei>..." zum Entfernen aus der Staging-Area)

        geändert:       CMakeConfig.txt
        geändert:       libs/pilight/protocols/433.92/CMakeExclude.txt
        geändert:       libs/pilight/protocols/protocol.h
        geändert:       libs/webgui/pilight.css
        geändert:       libs/webgui/pilight.js

Nicht zusammengeführte Pfade:
  (benutzen Sie "git reset HEAD <Datei>..." zum Entfernen aus der Staging-Area)
  (benutzen Sie "git add/rm <Datei>...", um die Auflösung entsprechend zu markieren)

        von beiden geändert:    libs/pilight/protocols/433.92/alecto_ws1700.h
        von uns gelöscht:       libs/pilight/protocols/433.92/gpsensor.c

So we are lucky, no path conflicts we do need to resolve, and I add all changed files to the index (stageing area):
Code:
root@pi_65:/home/pi/willem_4/pilight# git add CMakeConfig.txt libs/pilight/protocols/433.92/CMakeExclude.txt libs/pilight/protocols/protocol.h libs/webgui/pilight.css libs/webgui/pilight.js

If we continue now, GIT will still complain about the two files that were changed in both branches.
We do need to decide on what to do: "to remove or not to remove - that is the question".

While the header file has to be kept (otherwise the correspondig *c file will miss it), GIT does not know if gpsensor.c has to be added or removed, it depends on what the outcome of the action is.
As we are rebasing GPSprotocol and that file was part of the latest commit of the branch GPSprotocol, i decided to keep it.

So we continue by adding all remaining changes to the working area:

Code:
root@pi_65:/home/pi/willem_4/pilight# git add libs/pilight/protocols/433.92/alecto_ws1700.h libs/pilight/protocols/433.92/gpsensor.c
root@pi_65:/home/pi/willem_4/pilight# git status
Rebase im Gange; auf d2b181e
Sie sind gerade beim Rebase von Branch 'GPSprotocol' auf 'd2b181e'.
  (alle Konflikte behoben: führen Sie "git rebase --continue" aus)

zum Commit vorgemerkte Änderungen:
  (benutzen Sie "git reset HEAD <Datei>..." zum Entfernen aus der Staging-Area)

        geändert:       CMakeConfig.txt
        geändert:       libs/pilight/protocols/433.92/CMakeExclude.txt
        geändert:       libs/pilight/protocols/433.92/alecto_ws1700.h
        neue Datei:     libs/pilight/protocols/433.92/gpsensor.c
        geändert:       libs/pilight/protocols/protocol.h
        geändert:       libs/webgui/pilight.css
        geändert:       libs/webgui/pilight.js

Now GIT should be happy:
Code:
root@pi_65:/home/pi/willem_4/pilight# git rebase --continue
Applying: implementation of the General Purpose Sensor protocol

Job Done.
Let us now have a look at our history:
Code:
root@pi_65:/home/pi/willem_4/pilight# git log --oneline --graph --decorate -n10
* 181257a (HEAD, GPSprotocol) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
*   d2b181e (origin/development, development) Merge pull request #287 from mrWheel/development
|\
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?pid=18378#pid18378
|/
*   62e3f56 Merge pull request #284 from dominikkarall/development
|\
| * 1476cb1 change short pulse to 500
* |   a42a65e Merge pull request #283 from wo-rasp/tcm
|\ \
| * | 09d189b Bugfixing tcm protocol: structure tfa-> chenged to tcm-> for both battery objects
| |/
* |   ae2d5c4 Merge pull request #272 from dominikkarall/development
|\ \
| |/
|/|

Well looks pretty neat to me.
GPSprotocol is now based on (d2b181e).
That is the result wanted.

***********************************************
The only missing thing now is to get it saved on github.
AS I HAVE NO WRITE ACCESS TO THE  "MRWHEEL" REPOSITORY
i have to change the URL for origin:
Code:
root@pi_65:/home/pi/willem_4/pilight# git remote set-url origin https://github.com/xxx/dummy.git
YOU DO NOT NEED TODO THIS FOR YOUR OWN GITHUB ACCOUNT
***********************************************

root@pi_65:/home/pi/willem_4/pilight# git push origin --all
Username for 'https://github.com':
Password for 'https://xxx@github.com':
Zähle Objekte: 14011, Fertig.
Delta compression using up to 4 threads.
Komprimiere Objekte: 100% (3038/3038), Fertig.
Schreibe Objekte: 100% (14011/14011), 9.76 MiB | 42.00 KiB/s, Fertig.
Total 14011 (delta 10829), reused 13995 (delta 10819)
To https://github.com/xxx/dummy.git
 * [new branch]      GPSprotocol -> GPSprotocol
 * [new branch]      development -> development
 * [new branch]      master -> master
[/code]

"git log" now confirms that GPSprotocol is saved on the remote server and from github.com you can now either issue a pull request.
Code:
root@pi_65:/home/pi/willem_4/pilight# git log --oneline --graph --decorate -n10
* 181257a (HEAD, origin/GPSprotocol, GPSprotocol) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
*   d2b181e (origin/development, development) Merge pull request #287 from mrWheel/development
|\
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?pid=18378#pid18378
|/
*   62e3f56 Merge pull request #284 from dominikkarall/development
|\
| * 1476cb1 change short pulse to 500
* |   a42a65e Merge pull request #283 from wo-rasp/tcm
|\ \
| * | 09d189b Bugfixing tcm protocol: structure tfa-> chenged to tcm-> for both battery objects
| |/
* |   ae2d5c4 Merge pull request #272 from dominikkarall/development
|\ \
| |/
|/|
root@pi_65:/home/pi/willem_4/pilight#

Some more information on the usage of git rebase:

When you use the interactive rebase command an editor window opens and all commits selected will be shown in reverse order, AND the PICK is selected as the base command. You can now change the command, depending on what you want to achieve. In the editor window git is giving the user a selection of the most common options.

"git rebase -i" determines the parent commit and will run the commands from top to bottom, starting with the parent commit.

When you use PICK as your command, that changeset will be applied against the parent commit.

In your editor the most recent commit is at the bottom and the oldest commit is at the top. From top to bottom the script is run.
When the editor opens, git will assign the pick command to all commits.

If you re-order the sequence of the lines, the sequence in which the changesets are applied will change as well.

If you leave the first line as is and replace in the following lines the command pick with squash, those commits will be squashed into the previous one.

If you unintentionally issued the command AND you want to abort delete all lines without a # and save the file, GIT will abort the interactive rebase.

IF YOU ARE NOT SURE ON WHAT THE "rebase" command will do,
take the safe exit and abort.
 
Reply
#36
Wauw!

Git and wo_rasp keeps amazing me!

Yes, my understanding of git is growing, just not fast enough.

I will try this on monday. 

Just one question...
Won't it be easyer to delete my git(hub), re-clone my github from pilight/pilight, clone my github to my Raspberry, create the GPSprotocol branch and redo my changes (I have a copy of the changed files)...??

I understand this is a chicken way to go but I'm so scared to make a mistake (typo or what ever) and have to go back to you again to help me sort it out .. again ...

If so, I need to know how to retrackt my PR from the pilight/pilight repository.
 
Reply
#37
In short: there is no need to restart all over, just follow the steps I have outlined and try to understand what git does. At the end GPSprotocol is on top of development and you can leave it there until the pull request is accepted. You than merge the pull request from pilight into your development branch and after that it is time to delete your GPSprotocol branch as it is no longer needed. Your changes for the alecto protocol are already integrated.

Thus: why do you want do all that stuff again ?

Wiping everything out is a proven method to loose data (I did that myself several times as I too thought it to be the best way out - I am still sitting on a backlog of several branches, and branch by branch I am now getting out of it. I did a couple of small changes in my history log giving me headaches as they cause some little nifty conflicts during rebase and they require a lot of attention.

The worst thing you can do is starting a rebase with a repository that has uncommited changes, that's when GIT starts giving you real headaches, if there is a conflict.

To practice, I recommend that you setup an individual repository, you add one file (add three lines of text into that file) on the master branch, based on master you create two branches development_1 and development_2, and on development_2 you create a branch dev_21. You change the file and play around with git fetch, git merge, git rebase, git reset, and so on and compare if git and your expected result match - in the beginning they do not for most of the time. But based on that excercise you will gain confidence in your actions.

There is not a lot you can do wrong, I think GIT is a better goalkeeper for your code than anyone else.

A)
Go thru the following excercises:
1. Checkout master and add a 4th line of text to that file (you should never edit your files on master, bit this is the easiest way to create some conflicts). Add it ti the index and commit the change.
2. Checkout development_1 and change the 1st line in that file. Add it to the index and commit the change.
3. Checkout development_2 and change the 2nd line in that file. Add it to the index and commit the change.
4. Checkout dev_21 and change the 3rd line in that file. Add it to the index and commit the change.

B)
The task is now to incorporate all changes, before you contribute a 5th line as part of your development efforts and in addition to change line 4 using the branch dev_21.

C)
Before you start with part B) it is best to create a repository on github and save the complete repository on github. (You can than always recover by cloning the github repository back to your local computer, and use github to monitor your actions.)

D)
Develop a draft on how you want to proceed.
Some hints:
1. Do not push your commits to github, try different methods (git merge, git rebase) to achieve the task
2. As the master branch has diverged from all development branches, you may want to integrate them 1st, a less optimum way is to start with adding line 5 and changing line 4 in dev_21, pulling that into master and start updating the other branches afterwards.
3. At the end the content of the file should be the same on all branches.
4. Once Step 3 is finished push all branches on github (do not use the --all option, as in real life the development branches are the work product of different developers on different machines).
 
Reply
#38
@wo_rasp
Followed your instructions to the letter ..
Code:
~# mkdir pilightGPS

~# cd pilightGPS/

~/pilightGPS# git clone https://github.com/mrwheel/pilight.git
Cloning into 'pilight'...
remote: Counting objects: 15401, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 15401 (delta 1), reused 1 (delta 1), pack-reused 15398
Receiving objects: 100% (15401/15401), 10.95 MiB | 710 KiB/s, done.
Resolving deltas: 100% (11821/11821), done.

~/pilightGPS# cd pilight/

~/pilightGPS/pilight# git log --oneline --graph --decorate -n10
* 24e7387 (HEAD, tag: v7.0, origin/master, origin/HEAD, master) pilight version 7.0
* fa3139d Fixed teknihall protocol
* 3352845 Don't log pre-hashed password
* f566d33 Small fix in rsl366
* 7eba188 Allow new loglevel maximum
* 8607de9 Updated default config with updated settings
* cdcf4a1 Add newline to stderr message
* e81e790 Error check some mallocs
* eb60f80 Remove ntp-sync setting and just use ntp-servers
* caefc18 Rechecked log messages

.. that is, I missed one step Confused

Code:
~/pilightGPS/pilight# git checkout GPSprotocol
Already on 'GPSprotocol'

~/pilightGPS/pilight# git rebase development
First, rewinding head to replay your work on top of it...
Applying: implementation of the General Purpose Sensor protocol
Using index info to reconstruct a base tree...
<stdin>:43: trailing whitespace.
Copyright (C) 2014 CurlyMo & TheWheel 
<stdin>:54: trailing whitespace.
Copyright (C) 2013 CurlyMo & TheWheel 
warning: 2 lines add whitespace errors.
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): libs/pilight/protocols/433.92/gpsensor.c deleted in HEAD and modified in implementation of the General Purpose Sensor protocol. Version implementation of the General Purpose Sensor protocol of libs/pilight/protocols/433.92/gpsensor.c left in tree.
Auto-merging libs/pilight/protocols/433.92/alecto_ws1700.h
CONFLICT (content): Merge conflict in libs/pilight/protocols/433.92/alecto_ws1700.h
Failed to merge in the changes.
Patch failed at 0001 implementation of the General Purpose Sensor protocol

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

~/pilightGPS/pilight# 

I then edited the files. Removed the conflict from alecto_ws1700.h, changed nothing in gpsensor.c.
Then did not see your "git status" so went right on to:

Code:
~/pilightGPS/pilight# git rebase --continue
libs/pilight/protocols/433.92/alecto_ws1700.h: needs merge
libs/pilight/protocols/433.92/gpsensor.c: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

~/pilightGPS/pilight# git add libs/pilight/protocols/433.92/alecto_ws1700.h
~/pilightGPS/pilight# git add libs/pilight/protocols/433.92/gpsensor.c

~/pilightGPS/pilight# git rebase --continue
Applying: implementation of the General Purpose Sensor protocol

~/pilightGPS/pilight# git status
# On branch GPSprotocol
# Your branch and 'origin/GPSprotocol' have diverged,
# and have 1 and 3 different commits each, respectively.
#
nothing to commit (working directory clean)

~/pilightGPS/pilight# git branch
* GPSprotocol
  development
  master

~/pilightGPS/pilight#

"git log" looks the same as in your example though!

Code:
~/pilightGPS/pilight# git log --oneline --graph --decorate -n10
* 3d31205 (HEAD, GPSprotocol) implementation of the General Purpose Sensor protocol https://forum.pilight.org/Threa
*   d2b181e (origin/development, development) Merge pull request #287 from mrWheel/development
|\  
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supp
|/  
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\  
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Thread-Oregon-THGR122NX?p
|/  
*   62e3f56 Merge pull request #284 from dominikkarall/development
|\  
| * 1476cb1 change short pulse to 500
* |   a42a65e Merge pull request #283 from wo-rasp/tcm
|\ \  
| * | 09d189b Bugfixing tcm protocol: structure tfa-> chenged to tcm-> for both battery objects
| |/  
* |   ae2d5c4 Merge pull request #272 from dominikkarall/development
|\ \  
| |/  
|/|   

Did not know what you ment the first time but continued anyway:

Code:
~/pilightGPS/pilight# git remote -v
origin https://github.com/mrwheel/pilight.git (fetch)
origin https://github.com/mrwheel/pilight.git (push)

And then it looks quite different from your output and I don't know whether to start over again or not. Better wait for your response first.

Code:
~/pilightGPS/pilight# git push origin --all
To https://github.com/mrwheel/pilight.git
 ! [rejected]        GPSprotocol -> GPSprotocol (non-fast-forward)
error: failed to push some refs to 'https://github.com/mrwheel/pilight.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

~/pilightGPS/pilight#

Regards!
 
Reply
#39
Please stay away from "git commit -all", it is getting tiresome for me. You want to learn how git works. So please do what git is recommending you to do and that is edit the files and do a "git add", you missed those messages.




I am not at home right now, will look at it later on, but the only file you need to edit is the alecto Header file and you do need to add all files in the workarea to the index "git status" is asking you, please do it step by step and try to understand what git does. If i remember correctly it is a total of six or seven files, two of them are reported to be changed on both branches (alecto...h and gps...c).











Get used to do a git status before you checkout, merge, rebase, revert, or reset anything, as sometimes you really mess things up, in particular when you are not on the branch you think you are on and you perform a git merge.











"git log" will not report anything useful at this moment, as you have not yet committed anything to the repository.





Only "git status" is useful right now as it will tell about the differences between work area and staging area (the index).



Once "git status" is happy with you you can commit your changes to the "origin GPSprotocol" repository.
The sha code of that commit will ddiffer from mine, can you tell me the reasons ?






send from tapatalk
 
Reply
#40
(07-11-2016, 04:12 PM)wo_rasp Wrote: Please stay away from "git commit -all", it is getting tiresome for me. You want to learn how git works. So please do what git is recommending you to do and that is edit the files and do a "git add", you missed those messages.

Hm.. did not use "git commit -all" so don't quite know what you mean..

(07-11-2016, 04:12 PM)wo_rasp Wrote: Get used to do a git status before you checkout, merge,  rebase, revert, or reset anything, as sometimes you really mess things up, in particular when you are not on the branch you think you are on and you perform a git merge.

I don't think I did anything like that, just followed your instructions..


(07-11-2016, 04:12 PM)wo_rasp Wrote: "git log" will not report anything useful at this moment, as you have not yet committed anything to the repository.

Only "git status" is useful right now as it will tell about the differences between work area and staging area (the index).

Once "git status" is happy with you you can commit your changes to the "origin GPSprotocol" repository.
The sha code of that commit will ddiffer from mine, can you tell me the reasons ?

I was impressed that the sha code of mine was exactly the same as your's (3d31205) but now I see its not. Don't know why though.. Probably  because our eMail addresses differ..?

Still I'm stuck after two very extensive sets of instructions from you, for which I'm grateful, but I hoped the first would solve my problem (but did not) and this one does not lead me to the same status as you manage to accomplish in your setup...

It not only makes me feel quite stupid, but it takes a lot of your time too!
 
Reply
  


Possibly Related Threads...
Thread Author Replies Views Last Post
  Config issues from development to stable 8.0 terrar 5 1,346 10-28-2017, 09:56 AM
Last Post: curlymo
  Some issues going from dev to nightly. psbest 4 3,923 01-02-2015, 10:19 PM
Last Post: psbest
  [Solved] Webgui issues in webkit browsers lvdp 7 4,928 02-19-2014, 09:51 PM
Last Post: curlymo

Forum Jump:


Browsing: 1 Guest(s)