On 13/07/2019 20:40, CrestChristopher wrote:
I understand, what methods do I have to choose from ?
My goal is to take the snippet push it to a git, give the snippet a
distinctive name so I understand in the future what it means and it's
purpose, if it's possible to include a little description then
retrieve it or read it though the git; if that is considered a method
or context ? :-)
How doe you extract "snippets" in your current workflow? (you haven't
said if you are a Windows or a Linux person, or your area of coding, so
some of this is rather generic)
I'm thinking that you extract the snippet (highlight and copy to
clipboard..) to a file (in the snippets rep workspace). It could get a
random temp name..?
You add that file name to your snippets repository (git add xyz.tmp)
You commit that addition, and you enter, via your commit message editor,
the short subject line, and then the description of the snippet.
If you are smart with your script (everything after highlight/copy to
clipboard), you also rename the temp file to the snippet shortname, so
your worktree file names are meaningful. And the shortname can even be
pre-pended to the commit subject line.
At this point you have a local repository of all your snippets. The
descriptions are in the commit messages, as are the shortnames and
one-line subject titles.
You use git log --oneline (check the syntax;-) to get your list of all
the snippets.
test and refine.
Christopher
On 7/13/2019 3:35 PM, Philip Oakley wrote:
On 13/07/2019 19:50, CrestChristopher wrote:
On 7/13/2019 1:37 PM, Philip Oakley wrote:
On 12/07/2019 12:58, CrestChristopher wrote:
Is it possible to take snippets of code along while also including
a description of what the code is intended to do and push it to a
git, so I have a repository of code snippets,
It can be done. However there are a few issues regarding
'alignment' between the classic Git (take a snapshot of working
files) approach and your desire to also have 'context'.
What do you mean ?
A code snippet is not complete code. Git is designed to manage a
complete code base. Ancillary descriptions of the code are not linked
directly to the code within Git. Multiple code snippets are likely to
need to be arranged. These are some of the differences in 'context'.
since I know git is for version control as I tend to like to have
code snippets for reference ?
Valid points.
Also can you push files within a git to another git; for example,
push a repository or the files in the repository from github to
another git ?
No, not directly. One pushes the whole commit and it's ancestors to
the destination repo, so it is not selective. However if you have
resolved how you record the context then it's not a real problem.
What do you mean, resolved how you record the context ?
Correct, It was saying " you have worked out how to capture the
'context' (the points noted above)"
One option is to add each code snippet as a distinct snippet file
(maybe under a 'snippets' director?); Then add each snippet
individually and commit that snippet with a message that has your
"description of what the code is intended to do", and a Subject
that is "filename: short one-line summary". Then when you 'git log'
that snippets branch (oneline version) you get your 'catalog' of
snippets and can select as appropriate.
Git is normally incrementally additive while a snippet data base
considers each part as discrete, so one has to manage that difference.
Philip
I'm currently using github, although I want to run my own private
git that is turning out to be a problem getting a kernel updated.
I don't understand what you mean by the last part ?
The last part is the same as my comment above "Multiple code snippets
are likely to need to be arranged.".
If you already have a method in use (no matter how good or bad it
is), it is worth starting from there and then 'improving' it in the
direction of Git compatibility if you want to use Git. The
alternative is to choose an alternative storage technique if that
looks better, and then maybe store that entity in Git.
Picking the best bits of your current method will be a good start.
Philip
(from my new email address)
--
You received this message because you are subscribed to the Google Groups "Git for
human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/git-users/80c6321d-5342-c11e-9ed3-2a3674a1294b%40iee.email.
For more options, visit https://groups.google.com/d/optout.