• 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
#11
Quote:What does "git branch" output and what does "git log" (on development) output?

That answer is pretty complex.
Please check "man git branch" and "man git log" by reading the git manual pages.

Quote:    Thanks for your prompt reply.


    ~/pilight# git branch
    * GPSprotocol
      development
In this case, it shows all branches you have in your local repository.
the asterix indicates that you have checked out a branch called GPSprotocol.
If you created that branch while you were on branch development and issued the command
- git checkout -b GPSprotocol
that branch has inherited all properties from the rbanch development.

Quote:     
    ~/pilight# git log -2
    commit 08e140e23ce3bcfe953e2cd15fa7501d9e3ee646
    Author: TheWheel <Willem@Aandewiel.nl>
    Date:   Wed Jun 15 08:52:48 2016 +0200

        Change protocol Head, ID and Temperature conform specsheet.
        https://forum.pilight.org/Thread-Fully-S...cto-ws1700
       
        Corrections in protocol, header/id and temperature
        https://forum.pilight.org/Thread-Fully-S...700#pid177
       
        Change protocol Head, ID and Temperature conform specsheet.
        https://forum.pilight.org/Thread-Fully-S...682#pid176

    commit a2719cf492230146edf276baaf056121f3b54533
    Merge: 62e3f56 627c98f
    Author: CurlyMoo <CurlyMoo@users.noreply.github.com>
    Date:   Mon Jun 13 07:00:36 2016 +0200

        Merge pull request #285 from wo-rasp/dev_optional
       
        Update json elements with conftype DEVICES_OPTIONAL

    ~/pilight#


    The protocol changes (commit 08e140e23ce3bcfe953e2cd15fa7501d9e3ee646) are already committed by curlymo, so I'm al little surprised it stil shows as something that looks like it still needs to be done. Hm..
No it does not, it shows that your commit 08e140e is based on commit a2719cf4.
And that is exactly what you wanted to achieve (that your commit with all modifications is based on curlymo's commit.)
when you use the extended command: "git log --all --oneline --decorate --graph" you get a more detailed overview on the dependencies of the individual commits.
And when you issue the following command "git blame libs/pilight/protocols/433.92/alecto_ws1700.c" you will be surprised to learn, that git is able to tell all about the individual changes made: when, by whom, which line.

Remember that you originally had the following history:
Code:
* 7c51cac (HEAD, development) Corrections in protocol, header/id and temperature https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700?pid=17700#pid17700
| * 22bebd7 (origin/development) Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700?pid=17682#pid17682
| * f74c09c Corrections in protocol, header/id and temperature https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700?pid=17700#pid17700
|/
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional

You than pushed another repository with this histoy log with the famous commit 3939b77:
Code:
*   b40e91a (origin/development) Merge branch 'development' of https://github.com/mrWheel/pilight into development
|\
| * 22bebd7 Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700?pid=17682#pid17682
| * f74c09c Corrections in protocol, header/id and temperature https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700?pid=17700#pid17700
* | 3939b77 (HEAD, development) Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread-Fully-Supported-No-brand-temp-humidity-sensor-alecto-ws1700
|/
*   a2719cf (upstream/development) Merge pull request #285 from wo-rasp/dev_optional

Most probably you used "git commit --amend" to add the changes polino1234 was asking for and the result is the commit 08e140e.

I can't tell, for cloning your github repository will not reveal to me what else you did locally.
Use the following command: "git reflog" and most probably you will get a more detailed overview of the sequence of your changes to your git repository.

Quote:    I created a branch with the name 'GPSprotocol' that I'm now trying to work on to implement that protocol (see my post GPSensor)

That is exactly what you always should do. (Create a new branch based based on development, integrate all your work and once the work is done, squash the history and submit the pull request.)
If you use the same branch name development it will get confusing (you can do so, but you really really really do need to know what you are doing, thus i strongly recommend not to do so).
 
Reply
#12
It looks like the history is a bit messed up... There should also be a "Merge" commit in there, see https://github.com/pilight/pilight/commits/development and the latest commit d2b181e.

This is why it's good to create a new branch before working on a new feature Smile
Now, what you need to do is this:

Code:
git reset --hard a2719cf492230146edf276baaf056121f3b54533

To go back to the last commit that is the same for your repo and "upstream" (pilight/pilight). This removes all other commits from the history of your branch, but as you haven't committed any new work to the development branch, it is fine. Be very careful with this command though, it shouldn't be used often.

Code:
git fetch upstream
git merge upstream/development

To merge the changes from upstream into your branch. Now, you can run this command to push the fixed branch to your GitHub pilight repository. If this command doesn't work, add the -f option to the end of the command to force the update, as the latest actions may have changed the history of the branch slightly, which git notices.

Code:
git push origin development

Related GitHub help articles
https://help.github.com/articles/configu...or-a-fork/
https://help.github.com/articles/syncing-a-fork/
 
Reply
#13
(07-01-2016, 08:38 AM)pilino1234 Wrote: Now, what you need to do is this:

Code:
git reset --hard a2719cf492230146edf276baaf056121f3b54533
Oeps... seems I have lost my work on the gpsensor.c and .h files (they are gone :-( )
 
Reply
#14
Shiet :/
Now you've also become a victim of "git ate my work"... Nearly everyone gets there at some point or another...
It seems you weren't on the "development" branch when starting this fetch/merge procedure
 
Reply
#15
Big Grin 
(07-01-2016, 09:45 AM)pilino1234 Wrote: Shiet :/
Now you've also become a victim of "git ate my work"... Nearly everyone gets there at some point or another...
It seems you weren't on the "development" branch when starting this fetch/merge procedure
Pff... luckily Eclipse saves a history where I was able to pull from and retrieved my filesSurprised from..

So I change from one branch to another by git branch development and back to git branch GPSensor (as an example)!

If I change to development I can with no problem execute the 
git fetch upstream
git merge upstream/development commands?

And then the git push origin development command?

As I'm already developing in the GPSensor branch, shouldn't I als execute a git push origin GPSensor command?

I'm so overwhelmed by git. I've all the documentation and I try to read in it but it's just sooo much!!
 
Reply
#16
Ahh, that was indeed lucky. Sadly it's very common for people to lose some of their work when starting with git.

https://xkcd.com/1597/

git is quite overwhelming when you start learning it, but in the end it can be quite helpful. But you always have to be careful and think about what you are doing and what you are going to do next.

No, to change branch you use
Code:
git checkout development
to change to the development branch. "git branch" lists the branches that you currently have in your repository.

The last option in the "git push origin [word]" command states what branch you want to push your code to in your GitHub repository. So running "git push origin development" will push the branch that you are currently on to the development branch of your GitHub repository.
If you want to publish your GPSensor branch and the work you have done there, you would first need to switch to the branch, commit your changes (if you haven't already) and then run this:
Code:
git push origin gpsensor
This will create a new branch called gpsensor in your GitHub repository if it doesn't exist yet, and then push your local changes into it.

However, we were working on look at how to synchronise your fork with the main pilight repository.
If you don't want to publish your GPSensor branch yet, you don't have to. But it might be good practice to publish the updated development branch. So, do a "git checkout development" and then run the steps from before.
 
Reply
#17
Normally, you will only loose your work, if you panic !
It is very difficult to loose any work while working with git repositories !
In most cases you have only lost the <hash code>.

Your friend in such situations is "git reflog". It reveals your last commands and typically it will list the <hash code> you are looking for. You do need that <hash code> to recover your files.

Once you got the <hash code> from the "git reflog" printout, do a "git checkout <hash code>" to recover your files, if git is not reporting an error you got all files back.

The term "detached head" is used for commits that do not have an associated branchname, nothing more - nothing less.

Follow the instructions to assign a branch name to the commit you just recovered.

It is very important to memorize that a branchname is only a pointer to one particular hash code! Normally it identifies the tip of your development.

Backtracing from the tip is always a unique series of commits and if the tip is associated with a branchname this series of commits forms a branchline.
 
Reply
#18
Me again Tired

I have created a branche (GPSprotocol) local and also on GitHub.

I changed some files and I added some files. Also I executed the git add command for the files that I have changed and added.

Then I executed:
Code:
~/pilight# git commit
# On branch GPSprotocol
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified:   CMakeConfig.txt
# modified:   libs/pilight/protocols/433.92/CMakeExclude.txt
# modified:   libs/pilight/protocols/433.92/gpsensor.c
# modified:   libs/pilight/protocols/433.92/gpsensor.h
# modified:   libs/pilight/protocols/protocol.h
# modified:   libs/webgui/pilight.css
# modified:   libs/webgui/pilight.js
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# CMakeCache.txt
# CMakeFiles/
# CPackConfig.cmake
# CPackSourceConfig.cmake
# Makefile
# build/
# cmake_install.cmake
          .
          . (lots of files)
          .
# pilight-sha256
# pilight-uuid
no changes added to commit (use "git add" and/or "git commit -a")

~/pilight#

So, I executed "git commit -a":
Code:
~/pilight# git commit -a
[GPSprotocol 55df041] implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Proposol-General-Purpose-Sensor-Protocol
 7 files changed, 71 insertions(+), 4 deletions(-)

~/pilight# 

So far so good (I know that next time I have to execute "git commit --append" to get all the changes in one commit.

What I don't know is how I get this changes/commit in my GitHub repository. The GPSprotocol branche is there but it does not get updated with the new files..

So close .. and yet so far away..
 
Reply
#19
Never use the -a option. Go the a bit more tedious path and add all modified files using git add path/filename, otherwise you may add too many files to your repository.

git push origin gpssensor should do it, if not use https://github.com/mrwheel/pilight.git instead of origin


send from tapatalk
 
Reply
#20
(07-02-2016, 10:12 PM)wo_rasp Wrote: Never use the -a option. Go the a bit more tedious path and add all modified files using git add path/filename, otherwise you may add too many files to your repository.
wo_rasp, 
Thanks for your reply (again).
As you can see from my post I did "git add" all the files involved. The bare "git commit" did not do anything and infect git itself suggested to use "git commit -a" which indeed started the editor in which I could write why and how.

So I'm a little surprised of how I would/could have accomplished the commit without the "-a" option...
 
Reply
  


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

Forum Jump:


Browsing: 1 Guest(s)