WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: tips / lessons for patch submited from git  (Read 2660 times)

Offline nick65go

  • Hero Member
  • *****
  • Posts: 839
tips / lessons for patch submited from git
« on: March 06, 2023, 02:57:20 PM »
Hi, is any  experienced programmer here, willing to spare a little time to teach the summary of submitting patches from git?
I am not a programmer, so I do not know. But it will be interesting to know.

I can use " diff -U0 file.old file.new > x.diff "; I created also a git account. And then?
How to comment /open an issue? How to upload the patch, where, from where? How to ask for it to be approved / pulled / pushed into other person git?

YouTube links to learn by example will be nice also. Because reading tens of pages for a simple task is ... not productive, or my patience is low.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: tips / lessons for patch submited from git
« Reply #1 on: March 06, 2023, 03:49:09 PM »
IANAP but I use git. I usually have write access to my git repositories so the process is a little different.

But as you don't have write access to the git repository, I think you need to fork it first.

You don't generate diff files manually, git handles all that for you.

You can use the git(hub) web interface, or use a git client on your local computer. The git clients can be CLI or have a graphics interface. I use SmartGIT on Windows 10.

Offline mocore

  • Hero Member
  • *****
  • Posts: 642
  • ~.~
Re: tips / lessons for patch submited from git
« Reply #2 on: March 07, 2023, 01:57:52 AM »
>Hi, is any  experienced programmer here,
all though i  :'(  fail to meat this criteria , ... i do have access to a keyboard  ( non midi ) , and once mapped some samples on a akai


I am not a programmer, so I do not know.
generally i see these kind of statement/assertions written hear and there on the web... (and wander what they are raven about https://en.wikipedia.org/wiki/Raven_paradox )
??? do all programmers know git   ?...



any way  ;)
 to answer the subject of this topic generally where x = git ; how to do y with x 

 hear is a link to a quick reference for the git command line tool  which (hopefully) might be usefull to answer this AND similar questions
 ^---> ** https://learnxinyminutes.com/docs/git/

specifically wrt your question / specified work flow : "using git to create a diff"
this is the relevant section from the above link
Quote
diff

Shows differences between a file in the working directory, index and commits.

# Show difference between your working dir and the index
$ git diff

# Show differences between the index and the most recent commit.
$ git diff --cached

# Show differences between your working dir and the most recent commit
$ git diff HEAD

afair
to download and install git in core its possible to use
Code: [Select]
tce-load -iw git
** the (markdown) plain text from the above link can be found/downloaded @ https://raw.githubusercontent.com/adambard/learnxinyminutes-docs/master/git.html.markdown
it is also view able  @ https://github.com/adambard/learnxinyminutes-docs/blob/master/git.html.markdown  marked up with html  :o




« Last Edit: March 07, 2023, 02:00:12 AM by mocore »

Offline mocore

  • Hero Member
  • *****
  • Posts: 642
  • ~.~
Re: tips / lessons for patch submited from git
« Reply #3 on: March 07, 2023, 02:57:20 AM »
I created also a git account.

there are many domains that you could create an account for   git://   access ( git over http / https is also an option afaik)

with (afaik) hub lab and bucket being the most popular(ised)

ftr :  hear https://en.wikipedia.org/wiki/Comparison_of_source-code-hosting_facilities is a list .


to contribute to *some project* hosted on Xhub an account at Xhub could be useful

once you have an account

you can fork the project

git clone a local copy of (your fork of)*some project*
Code: [Select]
project_url=https://Xhub.com/*Xhub-user-name*/*some project fork url*
# when you don't need the full project history use the
#  --depth 1 argument
# to
# shallow clone - faster cloning that pulls only latest snapshot
$ git clone --depth 1 "$project_url" ;

this should/will be pre-configured with the Xhub / $user / $project URL as the "git remote"  (used for git  push / pull )

Code: [Select]
# https://stackoverflow.com/questions/10183724/list-of-remotes-for-a-git-repository
#list of any configured remote URLs
git remote -v

to let (any) git (client)  authenticate (as your user  account)
its usually possible to create an access token  for a user (or project  , if implemented by what ever git repo/host )

a token is like a temporary revocable password   ,  user / token 

once you have a token granting access to the remote

pick a  method  to give the git client access to your token

one way to let programs access relevant  auth info is the ".netrc" file

an example .netrc
 @ https://gist.github.com/technoweenie/1072829?permalink_comment_id=1503529
Code: [Select]
machine github.com
login technoweenie
password SECRET

machine api.github.com
login technoweenie
password SECRET

many other methods are available  : https://coolaj86.com/articles/vanilla-devops-git-credentials-cheatsheet/

im shore i have fudged / omitted some subtle but important detail(s) ...
perhaps the above has enough gist to spare the op/others  afew pages of scrolling :) 

Offline nick65go

  • Hero Member
  • *****
  • Posts: 839
Re: tips / lessons for patch submited from git
« Reply #4 on: March 07, 2023, 03:31:18 AM »
@mocore: many thanks!
I intended to emphasize more on words like "willing to spare a little time", and less on "experienced programmer" part. Instinctively I avoid (if I can) anything owned by M$soft (like github).
I do not intent to "fork" a project. I was just trying to contribute a little back. To make a small diff text file and send it; Not caring about fame/ ranking while using a nick-name.
My philosophy is to not complicate my life with things that I would not use often.

Offline mocore

  • Hero Member
  • *****
  • Posts: 642
  • ~.~
Re: tips / lessons for patch submited from git
« Reply #5 on: March 08, 2023, 05:02:12 AM »

I do not intent to "fork" a project.

as greg mentioned above
But as you don't have write access to the git repository, I think you need to fork it first.

... having a git account (unless you mean a local user called git ?)
 would imho usually mean working with the account server and other account-having-users

any who

idk if any one might find this script useful / interesting  ...

https://github.com/whiteinge/ok.sh - A Bourne shell GitHub API client library focused on interfacing with shell scripts

https://github.com/whiteinge/ok.sh/blob/master/ok.sh
https://raw.githubusercontent.com/whiteinge/ok.sh/master/ok.sh #plain-texta

perhaps some section idea of the script in quot above might inspire similar scripts for other git hosts ...


https://github.com/search?p=5&q=tinycorelinux&type=Repositories
it seams used by some projects relevant to tcl.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 713
Re: tips / lessons for patch submited from git
« Reply #6 on: March 08, 2023, 07:06:37 AM »
Here are one more link to learn git.

https://rogerdudler.github.io/git-guide/

Offline nick65go

  • Hero Member
  • *****
  • Posts: 839
Re: tips / lessons for patch submited from git
« Reply #7 on: March 08, 2023, 07:48:42 AM »
Thank you very much.
Everything started when juanito suggested to put my small patch on git for tinycore; git was an alien word for me.

 Looking at the overwhelming majority of information, I think I have bitten off more than I can swallow.
I don't think it's what I imagined at the beginning.
But it's good that we have all the information gathered in one post, easy to digest later, for amateurs like me.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: tips / lessons for patch submited from git
« Reply #8 on: March 08, 2023, 03:20:46 PM »
Even though IANAP, I find git to be absolutely essential for software development.

It really was an OMG moment, "how did I not know about this!".

For me, it did require a bit of effort. I can only do basic day to day git operations.

Offline mocore

  • Hero Member
  • *****
  • Posts: 642
  • ~.~
Re: tips / lessons for patch submited from git
« Reply #9 on: March 14, 2023, 02:26:09 PM »
I don't think it's what I imagined at the beginning.

begging the question what was your initial impression ?

afaik ! (g)its yan-dvcs
https://en.wikipedia.org/wiki/Distributed_version_control

..with fast(er) branching (i read some place today)


Offline polikuo

  • Hero Member
  • *****
  • Posts: 725
Re: tips / lessons for patch submited from git
« Reply #11 on: November 26, 2024, 04:58:01 AM »
What you'll usually need

1. Use the web browser to fork a project into your account.

2. Clone it to your local storage
Code: [Select]
git clone git@github.com:your_user_name/the_project.gitNote that you'll need to setup ssh access to github as they have changed their policy years ago.

3. Do your coding...

4. Check your status
Code: [Select]
git status
5. Save your changes
Code: [Select]
git add -A
6. Keep coding...

7. You blow up something and you want to discard the changes
Code: [Select]
git restore your_file
8. More coding...

9. All done, ready to upload
Code: [Select]
git add -A
git diff --cached # just to double check
git commit -m "some message about your change"
git push # upload to github

10. Open your browser, navigate to your latest commit and send a pull request.

11. Wait for someone to review and merge / reject your work.