Howto git PART 1

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

Howto git PART 1

#1 Post by Karl Godt »

As many have recognized, there is

https://github.com/puppylinux-woof-CE

Since there are not many contributors, I would like to give a tutorial about how to use it .

First , you'll need the git package installed, should be part of most common devx_puppy-version.sfs .

Second , open a console urxvt or xterm window in your preferred home directory and type

Code: Select all

mkdir puppylinux-woof-CE.d
Then change into that new created directory :

Code: Select all

cd puppylinux-woof-CE.d
Third - now the git part begins .
Type

Code: Select all

git init
which will answer
initialized empty Git repository in /root/puppylinux-woof-CE.d/.git/

then type

Code: Select all

git remote add woofce https://github.com/puppylinux-woof-CE/woof-CE
which will answer nothing

then type

Code: Select all

git pull woofce
that will download the woof and print into the terminal like :

Code: Select all

remote: Counting objects: 9530, done.
remote: Compressing objects: 100% (4818/4818), done.
remote: Total 9530 (delta 3973), reused 9071 (delta 3531)
Receiving objects: 100% (9530/9530), 19.89 MiB | 388.00 KiB/s, done.
Resolving deltas: 100% (3973/3973), done.
From https://github.com/puppylinux-woof-CE/woof-CE
 * [new branch]      firmware   -> woofce/firmware
 * [new branch]      master     -> woofce/master
 * [new branch]      testing    -> woofce/testing
From https://github.com/puppylinux-woof-CE/woof-CE
 * [new tag]         0.1        -> 0.1
 * [new tag]         woof-CE-0.1 -> woof-CE-0.1
You asked to pull from the remote 'woofce', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
Fourth , it ineeds to initialize the branches :

Code: Select all

git checkout firmware
will answer
Branch firmware set up to track remote branch firmware from woofce.
Switched to a new branch 'firmware'


and in the filer window you will see the created file and folder tree .

This has to be done for master and testing branches, too :

Code: Select all

git checkout testing
Branch testing set up to track remote branch testing from woofce.
Switched to a new branch 'testing'

Code: Select all

 git checkout master
Branch master set up to track remote branch master from woofce.
Switched to a new branch 'master'



#*** END of LESSON PART 1

Questions ?

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#2 Post by Karl Godt »

Continues here :
Howto git PART 2
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#3 Post by Flash »

Thanks for the How-To. Maybe the reason there aren't many contributors is that very few people know what git is or what it might be good for. For sure I don't have a clue. :?

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Flash wrote:Thanks for the How-To. Maybe the reason there aren't many contributors is that very few people know what git is or what it might be good for. For sure I don't have a clue. :?
Yup, for the average user means git, svn or cvs are just tools to download something that just does never compile anyway .

:)

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#5 Post by mavrothal »

Flash wrote:Thanks for the How-To. Maybe the reason there aren't many contributors is that very few people know what git is or what it might be good for. For sure I don't have a clue. :?
Git is a versioning system. ie it keeps track of the changes you make in a file or in a folder so you can know what is changed and why, and provide and easy way to go back if something is wrong or identify what exactly generated a problem.
There are many of these system. svn, mercurial and git are the most used. BarryK himself first created bones and then used fossil to track changes in woof development.
Git is arguably the most powerful of all and geared much more for collaboration with a lot of new features. The linux kernel and many other major projects use it.
Github is a web repository and interface for git-based projects, like woof-CE.

Oversimplifying, for the avid puppean it means in that instead of suggesting specific code changes in the forum can do that in git/github and a) make the life of a pupplet developer easier and b) get his/her name on the record. :wink:
For the pupplet developer, it means that whatever changes where made in the woof code can be shared with all the other developers easily and advance puppy in general.

In a nutshell, is something that makes it easy and efficient for people to truly collaborate in a project (in puppy "community edition" for example)
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#6 Post by gyro »

deleted
gyro

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#7 Post by slavvo67 »

Steps above lead to "Unable to Access 'https://github.com/puppylinux-woof-CE/woor-CE/': Problem with the SSL CA cert (path? access rights?)

Are others seeing this issue?

User avatar
nilsonmorales
Posts: 972
Joined: Fri 15 Apr 2011, 14:39
Location: El Salvador

#8 Post by nilsonmorales »

slavvo67
I use this script by D-coy

Code: Select all

#!/bin/sh
#Script para automatizar configuración de git y clonar repositorios remotos
#27122013 Escritor por D-coy
#27122013, GPL3 (/usr/share/doc/legal)
#27122013 nilsonmorales lineas de ayuda

# Configure user and mail 

echo -n 'Enter your User: '
read user
if git config --global user.name $user 2>/dev/null ; then
git config --global user.name $user
     
echo -n 'Enter your Mail: '
read mail
git config --global user.email $mail

#General Config
     
git config --global core.editor geany
git config --global core.pager ''
git config --global color.ui true
git config --global http.sslVerify false
git config --global push.default matching
git config --global push.default simple
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
echo -n "Do you want to clone a git project? s/n: "
read clone
if [ "$clone" == "s" ]; then

#Type repo/project link 
#Example: https://github.com/nilsonmorales/Badass

echo -n "URL to clone: "
read repo
git clone $repo
fi
else
echo 'You need "git" installed...'   
exit
fi 
The git config --global http.sslVerify false line help me to pass the SSL CA cert
[b][url=http://nilsonmorales.blogspot.com/]My blog |[/url][/b][b][url=https://github.com/woofshahenzup]| Github[/url][/b]
[img]https://i.postimg.cc/5tz5vrrX/imag018la6.gif[/img]
[img]http://s5.postimg.org/7h2fid8pz/botones_logos3.png[/img]

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#9 Post by gyro »

slavvo67 wrote:Steps above lead to "Unable to Access 'https://github.com/puppylinux-woof-CE/woor-CE/': Problem with the SSL CA cert (path? access rights?)

Are others seeing this issue?
Yes.
After

Code: Select all

git init
enter the following command

Code: Select all

git config --global http.sslverify false
as alluded to by nilsonmorales.

gyro

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#10 Post by MochiMoppel »

I feel very stupid. I've read step1-3, I created an account and I've downloaded puppylinux-woof-CE.d to my local HD. Now what? Still I can't figure out how to proceed.

This local puppylinux-woof-CE.d contains what status? It appears that the committed changes I see at Github are not included and that I instead have a copy of the same files that are contained in my Slacko 5.9. If that's true, wouldn't I then work on outdated files? And if it's not true, how do I make sure that my local copy is synced with the Github version?

How can I - in practical terms - change, test and upload a patch to Github? Let's say I want to patch the file /usr/local/petget/installpkg.sh. So I find the file in in my local ../puppylinux-woof-CE.d/woof-code/rootfs-skeleton/usr/local/petget/installpkg.sh.
My local ../puppylinux-woof-CE.d/ is just a bunch of files sitting on my HD, it's not a live productive environment and it's not a testing environment, so what is it? For making changes to a file I first need to have a test copy. Where do I put it? And when I have it, how do I test it "live"? I can always temporarily rename the current /usr/local/petget/installpkg.sh and replace it with my test copy. When I'm done I can save the changed file "somewhere" for later uppload to Github and rename the original /usr/local/petget/installpkg.sh. Sounds already terribly wrong.... :cry:

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#11 Post by gyro »

MochiMoppel wrote:I feel very stupid. I've read step1-3, I created an account and I've downloaded puppylinux-woof-CE.d to my local HD. Now what? Still I can't figure out how to proceed.
Join the club.
I've never been able to get Karl's method to work, i.e. where I could issue a pull request.
I used the following cheat sheet:

Code: Select all

On github:
 fork woof-CE.

In my git directory: 
 git init
 git config --global user.email euser@yahoo.com.au
 git config --global user.name ghuser
 git config --global http.sslverify false
 git clone https://ghuser@github.com/ghuser/woof-CE.git
 git remote add origin https://ghuser@github.com/ghuser/woof-CE.git
 cd woof-CE
 git checkout testing

apply patch(s) directly to local source file(s)

 git commit -a -m 'description of changes'
 git push origin testing

On github:
 create a pull request.
It may be overkill in some places, but it works for me.
Of course you need to edit "ghuser" to be your username on github, and edit the email address "euser@yahoo.com.au".

gyro
Last edited by gyro on Sun 11 Jan 2015, 10:21, edited 1 time in total.

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#12 Post by gyro »

MochiMoppel wrote:My local ../puppylinux-woof-CE.d/ is just a bunch of files sitting on my HD
Yes, what you get from git is just a directory of source files, as they currently exist in woof-CE.
MochiMoppel wrote:For making changes to a file I first need to have a test copy. Where do I put it?
After you have created a new version of a file and tested it in your local test environment, then you compare it with the original version of the file:

Code: Select all

diff -u filename.orig filename > filename.diff
Then you can directly "patch" the copy of the file in the git directory with "filename.diff", commit the changes, and push the modified branch back to github.

gyro

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#13 Post by MochiMoppel »

gyro, thank you for your kind response. I'm still not ready to cheat :lol:
gyro wrote:Yes, what you get from git is just a directory of source files, as they currently exist in woof-CE.
So you are saying that these are the most recent files, right? But even then, if I have a local copy, this copy gets old and needs to be updated - preferable in real time. Sounds impossible. Makes me wonder why I would need a local copy at all. So I tried to do as much as possible online. To stay with my example, I just logged in to Github, went to my fork and made some changes to woof-code/rootfs-skeleton/usr/local/petget/installpkg.sh. I then pressed "commit", believing that this would save the changes to my own forked environment.. I can see the diff between the original and my changed file. I can also comment on the changes. Are these changes visible to other members? And when I'm content with my changes, would pushing the "pull request" button initiate a ...you guess what?

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#14 Post by gyro »

MochiMoppel wrote:Are these changes visible to other members?
The woof-CE folk won't notice them until you create a "pull request".
MochiMoppel wrote:And when I'm content with my changes, would pushing the "pull request" button initiate a ...you guess what?
If you are happy with the diff, then try a "pull request".

I've never tried to modify my fork directly via github.
I always use a local test environment for my local version of the file. When I am happy that my changed file works, I then produce a "pull request" as outlined in my previous post, using the local changed version of the file that I used in testing.
Once the "pull request" is accepted or rejected, I delete my fork and my local clone. So next time I get a fresh fork and a fresh clone, that way I don't have to worry about keeping them updated.

Edit: I remembered why I clone a local copy of woof-ce.
I don't like to risk the possibility of introducing a typo into woof-ce by editing directly in github.
After successful testing, I "diff -u" the original version of the file with my modified version to produce a ".diff" file. I then use this ".diff" file to "patch" the woof-ce version of the file in my local git directory. Then I know that the code I tested is the code that ends up in woof-ce.

gyro

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#15 Post by MochiMoppel »

gyro wrote:
MochiMoppel wrote:Are these changes visible to other members?
The woof-CE folk won't notice them until you create a "pull request".
They may not notice, but the changes seem to be visible to anyone even without creating an account. Well , that's OK, only question is if it is more desirable to ask other members for comments at this stage or after a pull request.

The next problem: Now that I have committed my change, I can't edit the file any longer. I would like to add another change. How can I do this? Uncommit? The pencil icon which let me make the first change is not active anymore... :cry:

gyro
Posts: 1798
Joined: Tue 28 Oct 2008, 21:35
Location: Brisbane, Australia

#16 Post by gyro »

MochiMoppel wrote:The next problem: Now that I have committed my change, I can't edit the file any longer. I would like to add another change. How can I do this? Uncommit? The pencil icon which let me make the first change is not active anymore... :cry:
Sorry, don't know, never done editing or commits directly on github.
gyro

User avatar
mavrothal
Posts: 3096
Joined: Mon 24 Aug 2009, 18:23

#17 Post by mavrothal »

MochiMoppel wrote: The next problem: Now that I have committed my change, I can't edit the file any longer. I would like to add another change. How can I do this? Uncommit? The pencil icon which let me make the first change is not active anymore... :cry:
You just change the file and make another commit. There is no problem one change to be done in multiple commits. It's actually recommended! A pull requests can have multiple commits. :wink:
Alternatively you can revert the commit and start again, but you do not gain anything by this because at the end will be 3 commits. Original, reversion and the new one.
Plan C is to do hard reset (git reset --hard <commit hash>) to a previous commit that will both change the files and the commit log to a previous state. This is actually not recommended because you really lose all the info from that point forward.
== [url=http://www.catb.org/esr/faqs/smart-questions.html]Here is how to solve your[/url] [url=https://www.chiark.greenend.org.uk/~sgtatham/bugs.html]Linux problems fast[/url] ==

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#18 Post by MochiMoppel »

mavrothal wrote:You just change the file and make another commit.
But this was exactly my problem: can't do that. It turned out that this is a browser issue. I switched from Opera to Seamonkey, which - surprisingly - gives me a different tooltip for the right pencil icon (Something like: you have to choose a branch first). In Opera it's "make changes to the file" and the branch default can't be changed and is set to a cryptic number. "master" sounds a bit bold, but I hope it's OK.

So a "commit" is what? Just a copy of the original files with my changes?
Plan C is to do hard reset (git reset --hard <commit hash>) to a previous commit that will both change the files and the commit log to a previous state.
I wouldn't know how to do this online.
Attachments
Screenshot.png
(77.82 KiB) Downloaded 330 times

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#19 Post by MochiMoppel »

So many unanswered questions, so many wasted hours, so much frustration. I've deleted all of my test projects, I'm on the brink of giving up on github.

OK then, one last try. Step-by-step:

I forked woof-CE to MochiMoppel/woof-CE
From now I operate in the master branch of my forked version.
My goal is to make a change to 1 file, then issue a request to pull this change into the testing branch of the original woof-CE . Is this the correct approach?

User avatar
rufwoof
Posts: 3690
Joined: Mon 24 Feb 2014, 17:47

#20 Post by rufwoof »

MochiMoppel wrote:So many unanswered questions, so many wasted hours, so much frustration. I've deleted all of my test projects, I'm on the brink of giving up
Fortunately I didn't waste too many hours before losing interest and giving up.

Post Reply