• 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
#21
Git is managing three areas, Repository, Index or staging area and workspace.






"git status" reports differences between the index and workspace.






Files get edited in the workspace. The compiler is also adding files to that area.




When you want to commit files you do need to add them to the staging area (also called the index). That's when git adds all its housekeeping stuff. That's what "git add filename" does. You can select single files and you should do it that way, "git commit -a" adds all files and you typically may not want to add them all.




With "git commit" the index is copied to your local repository and the hash code is generated.




When you have a remote repository you can update that as well using "git push URL NAME_OF_REMOTE-REPOSITORY".




As a convention your URL is configured as origin and the URL of the pilight project is configured as upstream.



Typically you use https as transport protocol as it is the easiest to handle for most users.



With "git checkout -- filename" you copy a single file back from the repository to the index and workspace.



With "git reset filename" you remove a single file from the index.


Please note: "git reset" has a lot of different options and thus a lot of different meanings, in the context above it is basically the undo of "git add filename"





send from tapatalk
 
Reply
#22
(07-03-2016, 03:10 PM)wo_rasp Wrote: Git is managing three areas, Repository, Index or staging area and workspace.

Files get edited in the workspace. The compiler is also adding files to that area.

When you want to commit files you do need to add them to the staging area (also called the index). That's when git adds all its housekeeping stuff. That's what "git add filename" does. You can select single files and you should do it that way, "git commit -a" adds all files and you typically may not want to add them all.

With "git commit" the index is copied to your local repository and the hash code is generated.

With "git reset filename" you remove a single file from the index.

Please note: "git reset" has a lot of different options and thus a lot of different meanings, in the context above it is basically the undo of "git add filename"

What I read in "the documentation" is that "Untracked basically means that Git sees a file you didn’t have in the previous snapshot (commit); Git won’t start including it in your commit snapshots until you explicitly tell it to do so".

and 
commit -a
-commit -all Tell the command to automatically stage files that have been modified and deleted, but new files you have not told Git about are not affected."

As I told in a previous post I "git add" all the files I was working on but the simple "git commit" didn't do anything, accept suggesting to use "commit -a" Unsure so thats what I did.
I also did a "git push origin GPSprotocol" and now the modified and new files are in my online github repository. Sa far so good.

I made some more changes to some more files and everything now works as I want to. So, executed "git commit --amend" but it seems I had to "git add" the files that where modified since the last commit again. Did that and now the editor came up again and all looks well.

So to wrap things up I now execute the "git pull origin GPSprotocol" command and then:

Code:
~/pilight# git push origin GPSprotocol
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.
~/pilight#

"git log" ouput:

Code:
~/pilight# git log --oneline --all --decorate --graph HEAD -8
*   f38cf0e (HEAD, GPSprotocol) implementation of the General Purpose Sensor protocol https:
|\  
| | *   7909216 (origin/GPSprotocol) Merge branch 'GPSprotocol' of https://github.com/mrWhee
| | |\  
| |/ /  
|/| /   
| |/    
| *   d2b181e (upstream/development, origin/development, development) Merge pull request #28
| |\  
* | | 55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.or
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \  
| |/ /  
|/| /   
| |/    
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.piligh
|/  
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
|\  
| * 627c98f Update json elements with conftype DEVICES_OPTIONAL https://forum.pilight.org/Th
|/  
~/pilight# 

So I'm sure I have done something stupid again. Before I mess up anything even more I will wait for your reply....

Regards
 
Reply
#23
After "git commitment --amend" you need to add -f to the push command. GIT was assuming that your tip (commit f38cf0e, the HEAD is is not a parent of origin, so it fell behind, perhaps due to other users performing an update in the meantime and in that case git pull would have been the correct way of continuing). But with you being the only one this is not the case ... I think you understand. In case you Are not the only one contributing to your repository you should not use --force but --force-with-lease, in this case git will do additional checks and allow the force command to go thru only if no one else has changed the repository.




Yes you are correct after editing the file you need to do git add before git commit --amend (sooner or later you will drop the -a option, it took me several month to drop it).



So in short push your changes and force git to accept it.


send from tapatalk
 
Reply
#24
(07-04-2016, 09:33 PM)wo_rasp Wrote: After "git commitment --amend" you need to add -f to the push command. 

Yes you are correct after editing the file you need to do git add before git commit --amend (sooner or later you will drop the -a option, it took me several month to drop it).

So in short push your changes and force git to accept it.

YES!
It worked!! Thank you for that.

An other matter:
If have tried to save my credentials to a "store" and that works. So I don't have to add my username and password anymore but .. during the process I must have done something wrong that I can't get right anymore. Every time I (try to) push I get the following messages:

Code:
~/pilight# git push origin GPSprotocol -f
git: 'credential-' is not a git command. See 'git --help'.

Did you mean one of these?
credential-cache
credential-store
Counting objects: 27, done.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 1.05 KiB, done.
Total 10 (delta 9), reused 0 (delta 0)
To https://github.com/mrWheel/pilight.git
 + 7909216...3dab531 GPSprotocol -> GPSprotocol (forced update)

~/pilight# 


The credentials are saved and used from the store, so how can I get rid of the
Code:
git: 'credential-' is not a git command. See 'git --help'.
Did you mean one of these?
credential-cache
credential-store
messages???
 
Reply
#25
Those messages probably come from a syntax error in your gitconfig, it looks like one of the settings is misspelled.

Can you post the output of "git config --list"? This will show your full git configuration, so that we can see what's wrong. You can hide the email address in the output if you wish.
 
Reply
#26
(07-05-2016, 09:24 AM)pilino1234 Wrote: Can you post the output of "git config --list"? This will show your full git configuration, so that we can see what's wrong. You can hide the email address in the output if you wish.
Code:
~/pilight# git config --list
user.name=TheWheel
user.email=<email address>
credential.helper=store --file ~/.git-credentials
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://github.com/mrWheel/pilight.git
branch.development.remote=origin
branch.development.merge=refs/heads/development
credential.helper= 
credential.helper=store
remote.upstream.url=https://github.com/pilight/pilight.git
remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*

~/pilight# 
 
Reply
#27
I did it again (I thinkSurprised)

Just did a pull request and now if I look at pilight/pilight I see two lines:
Code:
implementation of the General Purpose Sensor protocol  55df041
implementation of the General Purpose Sensor protocol  9cdc7c1

This probably gave it away at forehand:

Code:
~/pilight# git log --oneline --all --decorate --graph HEAD -6
*   9cdc7c1 (HEAD, origin/GPSprotocol, GPSprotocol) implementation of the General Purpose Sensor protocol
|\  
| *   d2b181e (upstream/development, origin/development, development) Merge pull request #287 from mrWheel
| |\  
* | | 55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Pro
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \  
| |/ /  
|/| /   
| |/    
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.pilight.org/Thread
|/  
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
 
root@pilight7:~/pilight# 

Shoot me!!!

I think I need to do the following:
Code:
git log --all --oneline HEAD -2
9cdc7c1 implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Propo
55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.org/Thread-Propo

~/pilight# 

And than:
Code:
git rebase -i HEAD~2

And in the editor leave in the first line the command pick unchanged and change in the 2nd line the command pick into squash. Thus the commit 55df041 is "picked" as base and the files from commit 9cdc7c1 are squashed (merged) into it and the job is done...

If only life is that simple...

Unbelievable! I have PR against the Master branch.. Don't know how I did that. Don't know how to proceed..Angry

@wo_rasp: Please advice (again!)
 
Reply
#28
No, if you do this I am relatively sure you will loose some of your work.

You posted previously:
Code:
*   f38cf0e (HEAD, GPSprotocol) implementation of the General Purpose Sensor protocol https:
|\ 
| | *   7909216 (origin/GPSprotocol) Merge branch 'GPSprotocol' of https://github.com/mrWhee
| | |\ 
| |/ / 
|/| /  
| |/   
| *   d2b181e (upstream/development, origin/development, development) Merge pull request #28
| |\ 
* | | 55df041 implementation of the General Purpose Sensor protocol https://forum.pilight.or
* | |   09296d2 Merge pull request #287 from mrWheel/development
|\ \ \ 
| |/ / 
|/| /  
| |/   
| * 08e140e Change protocol Head, ID and Temperature conform specsheet. https://forum.piligh
|/ 
*   a2719cf Merge pull request #285 from wo-rasp/dev_optional
and
Code:
~/pilight# git push origin GPSprotocol -f
Total 10 (delta 9), reused 0 (delta 0)
To https://github.com/mrWheel/pilight.git
 + 7909216...3dab531 GPSprotocol -> GPSprotocol (forced update)

I am relatively sure that 3dab531 was your most recent commit.

I am sure that 55df041is an older version. This is why I am convinced that your strategy with "git reset" is wrong.

In order to find out what happened i do need the output from "git reflog".
Based on that information I am pretty sure that your most recent commit can be identified, and I am also pretty sure that it can be recovered.
 
Reply
#29
(07-05-2016, 09:29 PM)wo_rasp Wrote: I am sure that 55df041is an older version. This is why I am convinced that your strategy with "git reset" is wrong.
I take your word for that... Confused .. but I thought the "git reset" was about the alecto_ws1700 protocol. From there I created a branch for the development of the GPSprotocol..

(07-05-2016, 09:29 PM)wo_rasp Wrote: In order to find out what happened i do need the output from "git reflog".
Based on that information I am pretty sure that your most recent commit can be identified, and I am also pretty sure that it can be recovered.

I did a "git rebase -i" just to see what what the editor would show and not really to go on with it. That seems impossible (I probably should have removed all the lines before ending the editor).

Here it is (git reflog):

Code:
~/pilight# git reflog
55df041 HEAD@{0}: rebase -i (finish): returning to refs/heads/GPSprotocol
55df041 HEAD@{1}: checkout: moving from GPSprotocol to 55df041
9cdc7c1 HEAD@{2}: commit (amend): implementation of the General Purpose Sensor protocol
3dab531 HEAD@{3}: commit (amend): implementation of the General Purpose Sensor protocol
32be905 HEAD@{4}: commit (amend): implementation of the General Purpose Sensor protocol
04e579f HEAD@{5}: commit (amend): implementation of the General Purpose Sensor protocol
f38cf0e HEAD@{6}: commit (amend): implementation of the General Purpose Sensor protocol
2ab747a HEAD@{7}: commit (amend): implementation of the General Purpose Sensor protocol
7909216 HEAD@{8}: pull origin GPSprotocol: Merge made by the 'recursive' strategy.
55df041 HEAD@{9}: commit: implementation of the General Purpose Sensor protocol
09296d2 HEAD@{10}: checkout: moving from GPSprotocol to GPSprotocol
09296d2 HEAD@{11}: checkout: moving from GPSprotocol to GPSprotocol
09296d2 HEAD@{12}: commit (amend): Merge pull request #287 from mrWheel/development
d2b181e HEAD@{13}: checkout: moving from GPSprotocol to GPSprotocol
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
a2719cf HEAD@{18}: checkout: moving from development to GPSprotocol
08e140e HEAD@{19}: checkout: moving from GPSprotocol to development
a2719cf HEAD@{20}: reset: moving to a2719cf492230146edf276baaf056121f3b54533
08e140e HEAD@{21}: checkout: moving from development to GPSprotocol
08e140e HEAD@{22}: checkout: moving from development to development
08e140e HEAD@{23}: commit (amend): Change protocol Head, ID and Temperature conform specsheet.
c944d10 HEAD@{24}: commit (amend): Change protocol Head, ID and Temperature conform specsheet.
3939b77 HEAD@{25}: reset: moving to HEAD~1
b40e91a HEAD@{26}: checkout: moving from da569ab3ab8169ef62a22b01bca185150581cb46 to development
da569ab HEAD@{27}: rebase -i (squash): Change protocol Head, ID and Temperature conform specsheet.
ae2d5c4 HEAD@{28}: rebase -i (squash): updating HEAD
168e294 HEAD@{29}: rebase -i (squash): # This is a combination of 3 commits.
ae2d5c4 HEAD@{30}: rebase -i (squash): updating HEAD
7cdd7a6 HEAD@{31}: rebase -i (squash): # This is a combination of 2 commits.
ae2d5c4 HEAD@{32}: rebase -i (squash): updating HEAD
15d53af HEAD@{33}: rebase -i (pick): Bugfixing tcm protocol: structure tfa-> chenged to tcm-> for both b
ae2d5c4 HEAD@{34}: checkout: moving from fa2839c9ab9fe00ce37036835e5660cb7408de67 to ae2d5c4949372b83e61
fa2839c HEAD@{35}: commit: Change protocol Head, ID and Temperature conform specsheet.
a2719cf HEAD@{36}: rebase -i (squash): updating HEAD
3939b77 HEAD@{37}: checkout: moving from development to 3939b77
b40e91a HEAD@{38}: pull: Merge made by the 'recursive' strategy.
3939b77 HEAD@{39}: rebase -i (finish): returning to refs/heads/development
3939b77 HEAD@{40}: rebase -i (squash): Change protocol Head, ID and Temperature conform specsheet.
a2719cf HEAD@{41}: rebase -i (squash): updating HEAD
f74c09c HEAD@{42}: checkout: moving from development to f74c09c
22bebd7 HEAD@{43}: checkout: moving from a87b0ac5fbbe77b76b32dbb61db73a13acfe79d6 to development
a87b0ac HEAD@{44}: commit (amend): Update json elements with conftype DEVICES_OPTIONAL
627c98f HEAD@{45}: checkout: moving from 14445246cfd307d5268e41194033297001242e17 to 627c98f
1444524 HEAD@{46}: commit: Change protocol Head, ID and Temperature conform specsheet.
a2719cf HEAD@{47}: checkout: moving from development to a2719cf492230146edf276baaf056121f3b54533
22bebd7 HEAD@{48}: commit: Change protocol Head, ID and Temperature conform specsheet.
f74c09c HEAD@{49}: commit (amend): Corrections in protocol, header/id and temperature
e13681b HEAD@{50}: commit (amend): Corrections in protocol, header/id and temperature
7f815b4 HEAD@{51}: commit: Corrections in protocol, header/id and temperature
a2719cf HEAD@{52}: clone: from https://github.com/mrWheel/pilight.git

~/pilight# 
 
Reply
#30
On the 4th, you were working on
Code:
| | *   7909216 (origin/GPSprotocol) Merge branch 'GPSprotocol' of
https://github.com/mrWhee
(see your post and my reply on this forum.).
Yesterday you posted a log with commit f38cf0e as the tip
Code:
*   f38cf0e (HEAD, GPSprotocol) implementation of the General Purpose Sensor protocol https:
|\
| | *   7909216 (origin/GPSprotocol) Merge branch 'GPSprotocol' of https://github.com/mrWhee

The git reflog command reveals, that you continued working on that commit:
Code:
~/pilight# git reflog
55df041 HEAD@{0}: rebase -i (finish): returning to refs/heads/GPSprotocol
55df041 HEAD@{1}: checkout: moving from GPSprotocol to 55df041
9cdc7c1 HEAD@{2}: commit (amend): implementation of the General Purpose Sensor protocol
3dab531 HEAD@{3}: commit (amend): implementation of the General Purpose Sensor protocol
32be905 HEAD@{4}: commit (amend): implementation of the General Purpose Sensor protocol
04e579f HEAD@{5}: commit (amend): implementation of the General Purpose Sensor protocol
f38cf0e HEAD@{6}: commit (amend): implementation of the General Purpose Sensor protocol
2ab747a HEAD@{7}: commit (amend): implementation of the General Purpose Sensor protocol
7909216 HEAD@{8}: pull origin GPSprotocol: Merge made by the 'recursive' strategy.
55df041 HEAD@{9}: commit: implementation of the General Purpose Sensor protocol

So we now do know again the sha codes required to recover old versions.

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.
You can checkout the various commits, if git has overwritten files already, git will tell you.

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.

Remember, as said before the branchname points to a commit sha, nothing more, nothing less. The branchname is just a pointer to a commit.

You can look at your commit as a set of archived files, but you should look at two commits or a series of commits as a changeset.

Just another note: Be cautions with "git rebase" until you fully understand the power of that command and how it works, same with "git reset".

What does it mean: You used the git command "git rebase". With that command, you can change the predecessor commit of a commit or a series of commits.

If you do this it has an inpact on the tip:
Changing the predecessor of a commit means you typically change the "code base" and the changes in all following commits will be applied to that "code base". At a first glance it may look equal to a merge, but it is not, in particular when you have a tree structure of commits on top of that "code base".
 
Reply
  


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

Forum Jump:


Browsing: 1 Guest(s)