#help-with-git
1 messages · Page 3 of 1
With something like "git push -f <local branch>:branch_a"
A "headless" checkout of the commit hash works well for something like this
Does this make sense?
oh neat! I didn't realize that you could push commits onto upstream branches that is not the same as the upstream for the branch being pushed from.
Sure can! You will probable also be interested in the "-u" or "--set-upstream" setting; this will set the local branch to track whichever remote branch you specify
(So you don't have to keep specifying it)
When a branch is clean and you're about to do new work on it, git checkout -b my_backup_Branch helps a lot.
Just be careful with that -f
The trick is to erase them (or at least systematize how they are named) when their immediate utility is gone.
I also push to another directory on the same hard disk, as a local remote.
This way if it's really terrible, I just damaged an asset no viewing member of the public will see.
With recursive copying this amounts to 'free trials' to try out dangerous git commands with low penalty.
NGL a bunch of that went over my head. However, It''l be great fodder for google foo. The experimental pushes to a local remote is a great idea i never would have thought of .
Thank you (plural you)
To Hugo's point: doing a force-push is not ideal, and is not something you're supposed to do with remote branches anyone cares about
Definitely be careful
One thing I do sometimes, is to run the push without the "-f" flag
If it doesn't work, it's error message is helpful confirmation that I have the right branch
(Then I run the force-push)
thoughts on git cherry-pick ?
For a situation where you meant to push to a different branch, cherry-pick isn't advisable
It's really a kind of copy-paste, and doesn't maintain relationships the way merge does
I view a cherry-pick more as applying a .patch (or several) from another branch. That could be the original "wrong" branch, but it could also be for patching a change/feature/fix to a different version or branch without doing a full merge.
I ran the cookiecutter to create my library and pushed the code to my own repository. (Note: This is the first time I’m trying to do this outside of an existing Adafruit project.) It is failing pylint https://github.com/kmatch98/CircuitPython_DisplayIO_Animation/runs/2302161089. It doesn’t seem to be finding the library dependencies that I am using, (perhaps because it’s in my own repo and the libraries are in Adafruit_xxx_xxx ?). Did I do something wrong with the cookiecutter, or do I need to add something to help it find the imported libraries on GitHub?
One thing I notice, looking through the build logs, are the changes it's made to the .yml files, and the missing license file
https://github.com/kmatch98/CircuitPython_DisplayIO_Animation/runs/2302161089#step:11:30
But that's not what you were asking about...
I'm trying to recall the particulars for being able to reference the other libraries. I'm tempted to say it wasn't the requirements.txt, but a different file that helped resolve those. But it's getting late and I've blinked since the last time I looked at that, but checking now to confirm
Maybe I am remembering it wrong after all, and it is a requirements.txt file that's needed within the "examples" directory
Thanks Hugo, I’ll look at requirement.txt and compare with an existing library to search out differences. Thanks for a pointer on where to look.
Ok, I dug a bit more, and I think I see what's tripping up pylint... I think it's the from <library> import * where it doesn't see the functions translate and translate_relative, amont others, including the Animation class
Thanks so much for the help on figuring out the issues. You were right that pylint is not happy about import *. Also, it's strange that it doesn't recognize gc.collect as a valid command. I think it realizes that in the other Adafruit libraries. I will need to do some digging to understand why you had to override that one. Thanks for the help and for the PR!
My pleasure! It's not gc.collect() that pylint was displeased with. It was the gc.mem_free(). I wrapped those 3 calls with pylint's disable/enable for "no-member" and it was 100% happy with the CI
It doesn't seem like gc.mem_free() is standard Python, but rather, a Micro/CircuitPython add
Couldn't TG Techie (Jonah) simply have switched to a new branch from the current commit on the current branch? If they didn't care about the current branch.
I think it was that they didn't care about the current upstream/remote
I may have misunderstood the question but it seemed like the suggested answer was more work than necessary. I always read through this channel in case I learn something, and wanted to make sure I was understanding.
I think you're right, actually--I misread the combo of "push" and "wrong branch" as meaning the remote was wrong
But reading it again, it sounds like the changes were added on top of the wrong place
It was the "I don't care if I destroy the current branch" that made me think you could simply make a new branch and forget about the old one.
But now I see where you were coming from.
Which is the important thing right now 😄
I wasn't coming from anywhere--I was tired!
It sounds like they did care about the recent changes--which might be behind the cherry-pick question
Cherry-picking a commit or a range will definitely move valued commits. Rebase --onto will also do that: https://womanonrails.com/git-rebase-onto
@fair ingot kattni pointed out that your question was a little different than my reading -- you were on the right track with cherry-pick.
Ah yeah.
Ok, thanks for clarifying! I would have not been helpful if I had been around, as you can see. 🙂
Well wait a minute--you were helpful, in pointing out that the question was different than the answer
I suppose so. I hadn't thought of that angle.
That's what I was thinking as well kattni, about creating the new branch from the current one. But everyone was already well down the current path, and the person most affected was ok with the solution.
Also, that's why I usually visit every channel - might not help, but will probably learn something from it!
And because people are so wonderful here, if I ask a seemingly basic question, not being an EE, they'll share what they know 🙂
Something really annoying is happening to me
And I'd like to make it stop
In the beginning of my repository, I accidentally committed useless files. Things in .gradle or .idea and the like
And now that they're in the repository base, they keep showing up in my local changes, and they're super annoying
It's gotten to the point where I can't commit or checkout, or rebase some times because of file permission errors on those files
How do I make the repository "drop" these files?
I currently just have them in a separate change list I hide them inside of, but still they cause weird errors and clutter
That sounds bothersome! There are two helpful pages here and here:
https://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository?noredirect=1&lq=1
https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore
If I am reviewing and older PR for a CP library and want to make changes to the PR. Do I fork the repo, checkout the PR and then push to the same branch-name on my fork or do I push to the upstream(adafruit) repo ?
You'd work in your fork, and checkout the PR/branch
Then you could either a) create a PR to the branch of the original PR, or b) create a new PR with both changes against the Adafruit one
Thank you @spiral epoch
@lone cradle The GitHub CLI makes it super easy. Check that out next time. It basically does all the git magic for you.
But what Hugo said works as well.
I do use it for the checkout, but wasn't sure if would let. you push back. Very cool !
(I love that tool!)
Hmm, actually maybe I've not tried to push back with it. Maybe it doesn't let you? I feel like it can get you to a state to push back though.
I'll try it next time, thanks for the tip
You're welcome! Thanks for picking up older PRs!
Related to that, there is the CLI tool in action, both basically you can do both, I did that for this particular test. This is courtesy of @pallid thicket that made that video to explain to me what to do.
Sometimes with pushes that update a branch in a pull request, you're actually doing a "force push" to overwrite the old PR branch. Different teams and platforms have varying conventions around this one. Github definitely supports iterating this way. But many UI tools might hide/make it difficult to do this force push--for good reason.
I've never needed to force push to deal with updating an existing PR and discourage it if it's not absolutely necessary.
It depends how any PR issues are addressed. If any issues in the PR are fixed with additional commits on the branch being reviewed, then it won't need a force-push. But, the commit history will always hold code that was at-issue, followed by fixes.
A different way to address issues is by editing in-place, in the commit history. Any PR feedback is folded into the commit history, so the critiqued/updated code is fixed in the patch where it was introduced. This tells a better story, and the feedback stays in the PR page. Because this second kind of editing rewrites history, if it's pushed to the same branch/PR it will need a force-push. Many of git's features revolve around editing one's own history, to improve and clarify things in response to feedback.
This second way is a common way to edit PRs, and I thought it might be what the questioner might be running into. There's a little more about why/how github supports this kind of review and update cycle:
https://blog.adamspiers.org/2015/03/24/why-and-how-to-correctly-amend-github-pull-requests/
https://github.com/isaacs/github/issues/997
My guess is if I wait long enough they will add a command to the github cli so this requires less thinking 😉
Hah! Valid.
I've found that there are dangers with --force, however, something I learned from Scott during a deep-dive a while back, is --force-with-lease. Looking at the git docs for it, looks like --force-if-includes might be useful too. At least as far as ensuring that no commits or changes are lost.
https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease
Alright there, Steven Tyler! 😛
Unless the repo admin prevents for pushes 🤷
lol well, they don't at my job because they want a clean commit tree
this is why you fork the original repo and you can do it on yours
fork, branch, update, amend + force update, and then PR it
There's also the other option - git rebase -i *gasp* Which lets you do local updates, squashes, rewording, etc.
I would like to fork a specific example project in the Adafruit repo do I have to fork the whole directory of examples?
When you fork a repository, you're making your own copy of the repository under your own account. This is typically for times when you want to make changes to the code and then merge those changes with the "root" project.
It sounds like what you might be trying to do is just get the code for a single project, so that you can work with it, and not really have your changes merged into the original project. Is that correct?
It sounds like a clone with a sparse structure, since you don't want the whole codebase.
You can do that in 3 ways:
- Download a .zip of the repo, extract only the file you need and call it good
- Clone the repository locally, then delete any directories you don't need
- Perform a sparse clone, and checkout the directory you need
Ok I'll do a read on sparse clone. Thanks
Sorry for the mess :/
Not really. You can push it under a different name, and delete the one you originally pushed. I guess you could call that a rename?
You can do git push --set-upstream <remote-name> <new-branch-name>
$ git checkout -b newname
$ git push origin newname
$ git branch -D oldname
Oh, you can edit commits. It's particularly easy if it's just one
Don't forget git push -D oldname
To delete the remote branch too, if not done through the UI/site/etc
Thank you @waxen hill and @spiral epoch
gotcha lets try 🙂
Git, like C/C++, gives you a whole bunch of fun ways to shoot yourself in the foot - sometimes without a way to recover said foot!
If you clone from one hard disk directory to another you can practice without penalty.
lol
Good idea
Thanks
$ git remote -v > record.of.remotes
$ git remote add origin <foo>
$ git remote remove origin
origin is the customary for the first one but you can have more than one.
I use origin and also localorigin for my hard disk cloned dir.
I see
(I save 'origin' for github.com repo)
But note that if you clone a hard disk repo it gets named origin in the remote listing.
You can immediately git remote remove origin and then git add localorigin <foo>
I see I will try that first
That way the preferred name of origin always points to github.
(Some times you just don't want 'the public' to see all your mistakes)
;)
When I hit a checkpoint (good stopping place) I'll do this:
$ git checkout main
$ git checkout -b main-bbb-
$ git push localorigin main-bbb-
$ git branch -D main-aaa-
That way main-aaa- is only present locally until it's replaced by the next one in sequence.
But localorigin has the entire history of those like-named branches.
Be sure to use git branch -avv constantly, to keep aware of the current revisions of all branches, everywhere you have them (on all remotes).
Yes but git is a free software independent on github, although its used there
Hi. I'm about to push a PR to PlatformDetect, but I made a mistake on a previous commit. Now I'm trying to do a git rebase, but I don't get how to use it. I'm trying to run it with -i but I think I made it worse.
I'd like to push it with the Id of the first of the series, the one that failed and later fixed.
https://github.com/fede2cr/Adafruit_Python_PlatformDetect/commits/master
Hi!
I’m just getting started with Git, but this looks like it can help
I am planning to share my Particle IoT projects on GitHub. It is pretty similar to Arduino and uses the same language. The libraries are stored inside the project directory (under lib). Should I include the libraries while pushing it to GitHub, or just add them to .gitignore and put the links to the libraries on readme? Or is there a better way that I’m not aware of? Thanks a lot in advance :))
Libraries are all open source BTW, including some Adafruit ones
@earnest latch I think the larger projects use git submodules.
$ pwd ; cat .gitmodules
/some/path/to/pico-sdk
[submodule "tinyusb"]
path = lib/tinyusb
url = https://github.com/raspberrypi/tinyusb.git
branch = pico
$ git clone -b master https://github.com/raspberrypi/pico-sdk.git
$ cd pico-sdk
$ git submodule update --init
;)
image-drawing-with-python
good night I would like you to help me to show images in 32 x 32 and 64 x 64 thanks
pixel_pin = board.D18
pixel_width = 32
pixel_height = 32
https://learn.adafruit.com/easy-neopixel-graphics-with-the-circuitpython-pixel-framebuf-library/image-drawing-with-python
A good friend of mine won't publish on github .. because they demanded money from him. (needs verification!) -nis
That's why people use <foo> (where <foo> might be, say, sourceforge).
I had no idea.
github demanding money sounds like a scam. I've never had them demand money from me
In the past certain features (such as private repos) were paid; maybe they're referring to that?
ya, perhaps
Is there a way to port CircuitPython to Zephyr RTOS like this https://github.com/micropython/micropython/blob/master/ports/zephyr/README.md. I have ported micropython and now want to port circuitpython in QEMU for arm Mortex M3. Can someone please guide me with this. I searched a lot but couldn't find any documentation regarding this.
Seems possible, but a lot of work, and you will not find any documentation other than the official technical docs for Zephyr and circuit python. It is just a zephyr project like any other zephyr application
Maybe he's misinformed. I'll ask him again about it.
Thank you IOTPanic will try it out in the same way.
I tried but I don't think this can be done because when I run west build -b qemu_x86 ~/micropython/ports/zephyr command it is not executed because there is not a port of zephyr in the directory.It can be seen here https://github.com/adafruit/circuitpython/tree/main/ports as opposed to https://github.com/micropython/micropython/tree/master/ports/zephyr. Can anyone please shed some light on this and if it is possible how can it be done?
This is a very cool feature for GitHub to add... Sync fork with parent repo
https://twitter.com/github/status/1390382527588798477
Is your fork behind? You can now sync from the parent repo with just a single click! 🖱💥 https://t.co/4Zx6OwVTxO
2496
10753
circuitpython$ git submodule update
From https://github.com/tannewt/esp-idf
* branch d97b6863badec4643bf8d1d1058a65d723572882 -> FETCH_HEAD
Fetching submodule components/bt/controller/lib
Fetching submodule components/esptool_py/esptool
fatal: remote error: upload-pack: not our ref 09549c03111a2b330371d361d56227a457af66c5
fatal: the remote end hung up unexpectedly
fatal: remote error: upload-pack: not our ref ca8f5c602ec2948a31146b5f5e429dea369060a4
fatal: the remote end hung up unexpectedly
Fetched in submodule path 'ports/esp32s2/esp-idf', but it did not contain d97b6863badec4643bf8d1d1058a65d723572882. Direct fetching of that commit failed.
anyone have any idea what is wrong? this is after a pull from main on circuitpython repo
@cloud hound Did you try it again? Only suggesting that because of the "hung up unexpectedly" message. Wondering if it was a fleeting issue.
several times
and I checked my network connection, just to make sure, I can access github
Fair enough. I have no idea beyond that suggestion. I would ask in #circuitpython-dev simply for visibility. It's topical as well.
time for a fresh clone I guess
That was going to be my suggestion, as that's exactly what I would do, but I wasn't sure you'd want to go that route.
@cloud hound it could be the wrong remote
I think I had to do a couple updates in esp-idf too (so recursive)
@cloud hound the submodule remote is wrong... it needs to be adafruit/esp-idf...
you can try git submodule deinit -f esp-idf or rm -rf esp-idf and then initialize the submodule again.
a fresh clone helped
git submodule sync will sync the remote IIRC
thanks, I will try it next time
I ran my alias alias gitsubupdate='git submodule sync --quiet --recursive && git submodule update --init'
twice and that seemed to fix it. I may have rm -rfd esp-idf in between.
magic 🪄
can anyone help me with this issue?
running the script gives me the following error ` Installing build requirements - this may take a few minutes! Hit:1 http://deb.debian.org/debian sid InRelease Ign:2 http://obs.linaro.org/linaro-ov...
Unlikely unless you specify what script you're trying to run
And to boot, this doesn't belong here
this is the script
ok ty ill post it there
So, I'm reading thru Kattni's guide on contributing to CP with git/github. I'm a little confused on the concept of branches and updating branches -- Is updating something you should only do BEFORE making changes? Or do you want to update frequently while working on something? And if you're updating after working on something and merge branches, how does it handle differences like things you removed/added vs. things that were removed/added by others?
before you start on a change (that will turn into a PR), get your repo up to date, before you make the branch. Then usually you can just use that as the base for the PR. However, if there are upstream changes you want or need, to incorporate, then merge from upstream as appropriate, later, as you work on the PR. It is rare you need to do that. Some people rebase from upstream, though I find that rebase often causes more problems than it solves, even though it's a bit cleaner.
If there's a merge conflict from upstream, you need to solve it. I use git mergetool to do that, and use a GUI comparison tool. I used to use kdiff3, but it doesn't display that well in non-KDE environments, and now I use meld. I set my .gitconfig to specify that tool.
for any conflicting change, you'll need to think about what to take from the upstream change, and what of yours to keep.
I read this a long time ago, and found it helpful: https://git-scm.com/book/en/v2
Ohh, PDF, nice. I'll give that a read too. As Kattni said in the beginning of her guide... it's hard to explain! But I think I understand a bit better now, thanks :D
the git book explains exactly what a commit really is, and what branches really are, and that was enormously helpful to me early on.
Time to break out my Kindle for that book 
How did Travis CI get the name Travis?
possibly when they forked it from Jenkins?
So Travis was just a random name?
Ha, Travis the Tester instead of Travis the Tractor
Yeah, poor butlers, having to trail behind and clean up the code!
So... if I submit a PR, and someone else has a PR in for the same file(s), how does that work? Do they get merged during the PR process?
I don't know.
May get sorted by a human.
They can diff your PR to the old one, and also diff the other PR to the old one, then diff those two, maybe.
(never mind diff vs patch just the ideas there)
So you're asking if you and I are working on the same file, and PR at the same time, what happens?
GitHub is pretty smart, and as long as you're not working on the exact same section, there's no issue, each PR gets merged separately, and that's it. If you're working on the exact same thing, you'll end up with a "merge conflict", based on which one gets merged first. In that case, you'll need to rebase or incorporate the new changes into your code before yours, as the second PR, can be merged. It can also be done on GitHub if the conflict isn't too complicated, or manually within an editor.
the one that gets approved second needs to be rebased
Until one is merged, neither will show a conflict.
Indeed 🙂 But parts of it become second nature, the more you do it. For me, rebaseing is still nightmare fuel. But I've managed to do it without help a few times at this point.
The process from fork to merge doesn't seem too crazy complicated in itself, just a lot of steps and repetition
Exactly.
Oh, another question -- is there a way to be set up to move easily between computers while in the process of making changes? Like, working on CP stuff, I have the code either on the machine or on my server, so I'm not tied to one platform
Remote mount.
I would say, anyway.
Store it on one machine, and share the code out to the other. So you're really always working in one place.
OR.... Use Git/Hub how it was meant to be used
and always commit and push your code, then pull when you go to the other machine.
I'm terrible at doing that, so it's not my first thought 😄
I do that all the time.
clone to a test directory, make edits, push to github, cd to main directory, git remote update, pull, done.
The only scary part would be if I wasn't sure there were pending edits in the main directory that weren't pushed to github.
Ahh, ok, I didn't realize commits went to the cloud, I thought it was all local until the final push
Maybe I'll just have a Git VM for it, lol
@jade merlin Commits don't go to the cloud unless you push.
commit is local, push makes it remote.
$ cd ~/main_project
$ git remote update
$ git checkout main
$ git pull origin main
$ git push origin main # swap with above line as required
$ cd ~/some/path/TEST
$ git clone https://foo/main_project.git
$ cd main_project
$ edit myfile.txt
$ git add myfile.txt
$ git commit -m 'from test'
$ git push origin main
$ cd ~/main_project
$ git remote update
$ git pull origin main
Ahh
You can push without doing a PR. Two separate concepts.
You can push to your fork all day long and folks will only see it if they go to your fork and branch.
On GitHub.
Ok, that makes sense
So you can commit and push anytime to make sure your changes are safe from something happening locally.
And there's tricks to clean up the commit history if you want it to look nicer, but in CircuitPython Land, we welcome messy commit histories 🙂
Hehe. I'll try not to get too messy...
Oh, is there such a thing as too small a thing to work on? My intuition says no (especially for starting out)?
Of course not! We love all contributions. The little stuff has to get taken care of too.
We're currently really bad about labeling "Good First Issue"s. So don't use that to pick something. We need to be better with that.
Ok, good, I can leave the big scary stuff for you and the other seasoned folks XD
But yeah, you find a misspelled word or somewhere needing a comma or something, PR it!
I shall fix ALL the grammar!
You'll eventually end up writing a library for us 😄
Hehe
Alright, I need to step away for a bit. Keep asking questions as you go! We're here to help. We want you to contribute in whatever way works for you, so start wherever makes sense.
Thanks! Ttyl ^_^
I've been looking around but I'm a bit hopelessly lost. Is there a style-guide or other requirement / recommendation document to reference, if I want to contribute to an Adafruit library? Specifically an Arduino one, in this case.
I'd recommend starting here: https://learn.adafruit.com/contribute-to-arduino-with-git-and-github
So, general question... If you want to ask for/recommend features for something on GitHub, would you open an "issue" for that? Or is there a more appropriate way to do so?
ya, an issue is usually the right way. usually there is an enhancement label to tag it with
though you may need to be a maintainer to label it
Ok, cool. I have a bunch of suggestions for todbot's Staroids game XD
Thank you, I'll start working through that first.
I've got a git rebase question.
So, when I'm developing code, I'll sometimes have a couple parallel branches going (say for a bugfix and another for some new features). I'll submit a PR for the bugfix to be implemented, and it'll merge back in to main (All great at this point). However, that feature branch now needs to be synced up with the bugfix code. I typically will rebase the feature branch to start from the updated main branch.
The issue I run into is that I will get some conflicts if I've pushed the feature branch to a remote repo. Usually what I do is delete the remote branch, and then push again. This clears the problem, but feels a bit kludgy. Is there a better way to do this?
You can do --force-with-lease when you push
that'll change the remote branch even though it wasn't related to the previous state
the lease part of the flag means that git checks to make sure your local copy of the branch still matches the remote one before changing it
Awesome, thank you!
Fwiw, I'm a proponent of making a merge commit unless there's some specific reason not to (and even then I reserve the right to disagree with the reason 😛). I.e., in the above described situation, after the bug fix PR is merged into main, pull those changes into your local main branch, then merge main into your feature branch. This will:
(a) Create a merge commit, which correctly records the history of how your feature branch was developed. By contrast, if you rebase, it makes it look as if you (the author of the feature branch) were looking at the bug-fixed code when you first sat down to write the feature code. If someone later needs to understand the history (e.g. if they are tracking down a second bug that was introduced around that time), the doctored history created by a rebase could confuse them. In addition to the general "what were they thinking?", also (for example) tests that you reported as failing during an early commit of the feature branch may pass for the rebased version of that commit.
(b) References to specific commits (e.g. in later commit messages, or bug reports, or permalinks to code on GitHub/Lab/etc.) stay valid.
(c) No complaints from the remote when you push.
[Hm, I seem to have put most of the meat in (a).]
Thanks for the perspective. You make some good points. I'll keep that workflow in mind in the future to see what works best for me. It definitely has some advantages over rebasing.
What are the steps to follow (or the guide I'd need) if I want to locally run and test someone's branch build of circuit python? (In this I want to build and test this pull request: https://github.com/adafruit/circuitpython/pull/5348/commits/e544909b5b498322e6645ed61cb5c63741f64484 but I'm not sure the most flexible way to do it so I can easily update it if there are future changes or other branches to test)
I think you'd have to fork the source repo. Then you could easily update as needed via git pull.
And of course, I should have looked at the PR first. I see it's already been merged, so it's easy to check now...
in your cloned repo do git remote add name url-to-repo and then you can switch the branch using git checkout name/branch
Ok, thank you. And yeah, since then it's been merged, but as a general idea it's a skill I wanted to learn so it's easier for me to test pr's. Thanks!
in the case of 5348:
git remote add tannewt https://github.com/tannewt/circuitpython.git
git checkout tannewt/fix_s2_hang
This will let me test pull requests from other users as if it were only a branch on the main repo?
*and easily swap between the request and the main of the repo?
yes you can easily switch between different forks and their branches
example if you want to switch back to your own branch use git checkout origin/main.
origin is the remote from which the repo was cloned
Fantastic! Thank you for the explanation! I just couldn't keep that section of the git workflow clear in my mind, I really appreciate it!
happy to help! 🙂
I'm hoping someone can help me with a big oops. I accidentally committed a change that included a hard coded password that was supposed to be in a non-tracked secrets file. I know big oops. There is a fair amount of history after the commit, but thankfully I haven't pushed so it's only on my computer. How can I remove one line from a commit?
Nevermind. I figured it out. I created a new branch before I added the secret and cherry picked the commits back into place. Seemed to work okay.
Glad you figured it out. In the future, "git rebase" is your friend. There's an interactive mode where you can edit an old commit and then replay the rest of the history on top of it.
You can use gh for getting PRs checked out as well, using the GitHub CLI. It's a brew install if you're on Mac, not sure for other OS's. It basically does the git checkout magic in the background with a single command. If you click "Open with" which is on the left, opposite the title of the PR, it will tell you the command to type specifically for that PR, such as gh pr checkout 5298 to check out 5298.
Then do git switch main or whatever branch you want to get back to when you're done.
Oh I'll have to look into this! Thank you!
if you were tasked with (or tasked yourself with) setting up an "enterprise" git solution for one or two coders, would you use GitHub Enterprise, SourceTree, or some other method?
I would just use GitHub and create an organization with some private repos. That is free: https://github.com/pricing
If you want more, Team is quite cheap. Even "Enterprise" is not bad. I think that's the "Enterprise" you mean.
Yeah I wasn't sure if I needed their enterprise plan or not, I don't need a CI/CD setup either. My job exists in part because the code for a project was stored on a micro SD card in a pi, which was regularly improperly power cycled. I'd like my org to have a more robust system, even if I'm the only one looking at it. Thanks!
Adafruit seems to use GitHub to store Eagle files successfully. Does it work as well with other CAD programs?
Not always. Eagle uses an XML file format, so it's text-based and has reasonable diffs, which git likes. Many other CAD tools often have some binary blob file format. You can still store them in git, but it can't merge or diff them intelligently.
Sometimes it's part of the CAD tool itself, so it can handle collaborative editing in a way that makes sense for the design.
Glad you got the advice you did, because this message looked in danger of falling prey to two tech company extortion tropes: (1) calling their product a "solution" without mentioning the problem it is supposed to solve; (2) using the word "enterprise" at all tbh, let alone for 2 people. Theoretically "enterprise software" is a real and useful thing, but afaict, at the current economic moment, its direction is being steered by excited investors and a new wave of tech monetization strategies.
🙂
yeah I don't think I'd have a problem getting my grandboss to pay for the cheapest paid version, but I don't want to pitch any new expensive software, I just asked for a fusion 360 license!
is Github a good place for long term storage of code? Currently all the code for the projects I'm working on is stored on flashdrives, I would like to correct that
As good as any place on the internet, which is to say, in the end, it might all be ephemeral. 🙂
(Short answer: yes.)
Cool! Just working on a proposal:)
The nice thing about git is that it is easy to push your code to multiple locations by setting up multiple remote repos and pushing to all of them.
Does github desktop work well on a pi 3 A+ or should I get comfortable with command line git?
They have exactly the same performance. But it's probably still a good idea to get comfortable with the command line since it's a) not hard and b) good to know your tools.
And when I say "same performance" it's because the desktop is simply a UI over top of the command line.
@full steeple I use GitHub as a backup. I prefer the cli because the UI is the same across more OSes and over time.
Ah cool! I'll teach myself how to CLI
I wrote a guide for it. 😄
It's titled specific to CircuitPython, but the workflow is solid for any project. Don't let the specificity turn you off to it.
you might also consider GitLab, which is not owned by Microsoft.
I'll consider!
when i git clone a github repository, does my clone automatically have write access to that repo? Does cloning create a fork?
No and no
fun, so how can I use the CLI to get a writeable repo onto my pi?
You can always write to your local copy, it's just that you won't be able to push your local changes to GH unless your account has been granted push access to the repo
If you own the repo, then you have access
ahhh so I'd have to set up the pi with my account somehow? Or allow the pi?
Wherever you are editing the code, if you want to push from there, you will need to log into your gh account when you push. If the remote is https, then the command line tool gives you a prompt to do this, and I'm sure the GUI does too. If the remote is SSH, then you can authenticate via your SSH key rather than interactive password prompt.
See github help docs for "setting up SSH keys"
You can see the remotes by running git remote -v. HTTPS remotes start with https://, SSH remotes start with git@github.com
There doesn't seem to be a GUI for the Pi as of yet. Thanks for the tips, I'll probably need to get more clarification in the future
I highly recommend this book for understanding git: https://git-scm.com/book/en/v2
It's linked in the pinned messages for this channel.
Thanks!
It takes repetition. It was stilted, awkward and difficult for me initially, but my standard workflow is now second nature to me. When issues crop up, I'm sometimes back to noob, but for the most part, I've at least figured out most of what I need on a daily basis. You'll get there.
Thanks. Love this server
Anybody else getting this?
Submodule path 'ulab': checked out 'b913d064e525f674d0219524988e6d9d834fe09c'
fatal: remote error: upload-pack: not our ref 531cab9c278c947d268bd4c94ecab9153a961b43
fatal: the remote end hung up unexpectedly
Fetched in submodule path '../lib/axtls', but it did not contain 531cab9c278c947d268bd4c94ecab9153a961b43. Direct fetching of that commit failed.
@cloud hound Sometimes when I see that I just repeat the command and it works. But there were also GitHub issues today: https://www.githubstatus.com/history
I am using one of the "colorblind" themes in GitHub, available in Feature Preview. A number of red/green distinctions are replaced with orange and blue and similar colors. It makes it easier for me to spot failed builds. The blue is a little bright but I'm getting used to it.
I have a colorblind friend, let me check if sourcetree has the same thing
Very neat, love accessibility in software
So I wanted to delete all the local branches except main for a local repo. I found the following command. Does this look like it'll do what I want? git branch --merged main | grep -v main | xargs git branch -d
@plucky nacelle Your git fu might know the answer to this.
There's a lot to do it manually.
good question... that will be deleting branches locally, is it what you want?
as opposed to removing them on github
@sturdy talon ^
OK
Then it's good?
the only caveat I'd give is, if you had a branch where part of the name was 'main', such as 'romaine-lettuce', this would skip deleting it
because the middle part is asking for lines that don't have the substring 'main' in them
Ahh.
I suppose that's ok
better safe than not
I can manually catch any others.
hmm, skipped 4. Not sure why. They don't have main in them.
are they not fully merged?
hum I went through that process and I still have 119 local branches on my main development computer for circuitpython
I think you're right that they might not have been merged. I decided not to delete them in case I had working stuff in there. @plucky nacelle
If you want to think of branches as things under active development and also keep the old stuff just in case, you could tag the head of the old branches and then delete the branch. I once saw someone who had tag names like archive/foo for that purpose.
Hmm. Fair enough. I don't do enough with tags to have anything like that in my workflow, and I feel like it would end up a bit like hoarding, where I would collect all those tags and do nothing with them. Heh. Good to know though.
Oh, yeah - I would only do that to get the hoarding out of the way so I have peace of mind to prune the branches 😆
That's entirely fair!
I figured most of the code was on GitHub already, and I couldn't think of a reason to need to go back to them, and I'm lazy and wanted to be able to potentially reuse branch names. 😄
docs-fix is so easy.... but I've used it so many places already, I have to come up with iterations.
docs-fix-final-v2real?
I definitely have a retry limit where if the first N obvious names are taken, I stop trying to make a descriptive name and save that for the PR title
how do I pick between these? It seems they are all public licenses?
or do I not need a license if it's a private repo?
Yeah, if you don't plan on publicly releasing things, you don't need a license.
makes sense
Having an issue switching over to my work github account in github desktop. It tells me my global email is wrong (which it is, in green) but when I click update email, nothing changes. I have also gone into Options>Git and updated my email
if you do this in a console/powershell/whatever:
git config --global --list
Which one does it list under user.email=
I'm not sure now what I did in desktop mode but somehow I fixed it. My work code is pushing to the right place and everything. Noted for next time though, thx
noice
I always trust the console when dealing with weird git stuff. If I'm lazy I use VS Code or Desktop
Makes sense, I'm still getting used to the cli
I was looking for code to rotate my tft in Adafruit GitHub and found a bad link. I did the github thing and cloned the repository, made a new branch and made a pull request but the page was archived so no changes were possible.
"This script/repository is deprecated" it said, "go to this page for a newer script". But the link went to 404. ☹️
Is there a way to update an archived repository?
This page:
https://github.com/Adafruit/Adafruit-PiTFT-Helper
(This is a deprecated page with this link to a newer page.)
The link to the newer page:
https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/adafruit-pitft.py
(This link shows a 404 page because master should be main.)
and it should be this link:
https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/adafruit-pitft.py
@waxen raft Not quite sure what you wanted to do.
Hi @waxen hill! I was trying to update a link on an archived page
It goes to a 404 page
So you want to improve an archived resource for others looking at it - is that the only goal?
The page says, this is deprecated, go here for new stuff, but the link doesn't go to the new stuff.
It would be nice if it did
I'm guessing you'd have to email somebody since it's archived and marked read-only.
Maybe open an issue if that's not locked.
Ooh, I can open an issue, Thanks @waxen hill
I get this:
Branch not found, redirected to default branch.
and my browser says this in the address bar:
https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/adafruit-pitft.py
so to me it looks like github.com redirects the ref to branch master to main by itself.
whoops, the issue tab says:This repository has been archived by the owner. It is now read-only.
redirect result
Yes, but I get a 404 even though the master has been changed to main because the URL ends in .sh instead of .py
What exact link/address produces a 404?
I get a redirect off of that one:
https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/main/adafruit-pitft.py
That one is right.
This is the one that gives me trouble: https://github.com/adafruit/Raspberry-Pi-Installer-Scripts/blob/master/adafruit-pitft.sh
It's on this page: https://github.com/Adafruit/Adafruit-PiTFT-Helper
The archived page featured a script, the updated page features a python script.
you might try forking both repositories; if that doesn't work, maybe clone the one that can no longer be forked.
I have it forked, what should I do with it?
I would edit it in parallel with the original to bring it to what changes you wanted.
Yes, I did that.
Sharing it to the public would be another matter. Maybe contact the read-only repository editor(s) via email to let them know your intents and link to the editted forks/clones.
Or file a new issue on the read/write (current) variant.
Yep, that's a good idea.
Keep in mind that if you have an exact copy of any branch of any repository (unmodified by you) you can git checkout -b newbranch while in the original.
Then do anything you want to it.
Thank @waxen hill!
Just before a merge, I do that on the target branch, to verify I can get a Fast Forward style merge.
Much (much) easier to do that to verify merges before committing them to 'permanent' records.
$ git checkout private_idaho
$ edit thisfile.txt
$ git add thisfile.txt
$ git commit -m 'message to document change'
$ git checkout main
$ git branch # verify you are in maain now
$ git checkout -b test-main-delete
$ git branch # verify where you are
$ git merge private_idaho
I use:
$ git branch -avv
to get an overview of all known branches.
also:
$ git show | sed 3q
that gives me info on the branch I'm in now.
total noob when it comes to github and using the CLI. How can I push code from my pi directly to my main branch of my repo?
git push your-remote-name main where your-remote-name is the name you called your remote, and if you didn't set anything specific, it will be origin. You can find out by typing git remote -v and you'll get a list of remotes.
interesting ok. How can I clone the repo onto my machine?
my pi that is
ah it would be git-clone something right? I should probably change the default password on the pi first.
git clone -o oatsnhoney github.repo.url where oatsnhoney is your GitHub username. Then your remote-name would be your GitHub userID instead of origin which on a grand scale, is confusing.
How do I know that my pi has read/write privileges?
rw privs to what?
to the repo
Oh. When you try to push to it, if you used http for the URL, it will ask for your login creds at that point, and that's how you'll give it access. If you setup SSH, it'll ask for your key or fingerprint verification or whatever once, and then you have access after that.
I do recommend SSH, as a side note, but it requires some setup.
ok thanks, how would it help me?
eh I can google that
how do I push something to the codebase folder with CLI?
my url is https, are you saying omit the s?
You make local changes to it, and then git add those changes, git commit those changes, and then when you git push remote-name branch-name it will only update that directory. As long as you only added changes made to that directory.
Nope! I meant https.
ahhh ok, I need to clone first. also thanks re: https
I need to get good at this for me to feel like a real programmer.
You'll get it. It takes time. Repeatedly doing the same few commands. Then it all becomes second nature.
huh it seems like remote access was disabled on aug 13
I need some kind of auth token
let me google
here's where I was sent by the CLI, for reference https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
Beginning August 13th, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.
Hmm.
Ah. ok. So you generate a token, I think, give it perms, and then provide the token to the CLI.
I setup SSH ages ago, so I don't remember this part. 😕
maybe I should change the password and then setup SSH to github
this is all kind of confusing, I'll see if setting up SSH fixes the issue.
SSH setup might also be confusing. Hopefully not.
Hi folks! I forked a repo then totally messed it up. How can I erase my repo and start over?
@sturdy talon how did you determine what to put in here:
Idk if I needed to green that out
Turns out I wrote a guide on that for different reasons, but the concept is the same. https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github/starting-over-fresh
You have to generate an SSH key, I think.... It's super fuzzy now.
OOh, thanks @sturdy talon . Nice to meet you, by the way!
Nice to meet you as well! And you're welcome 🙂
Where did that come from?
first few lines of that article
oops nevermind
from the linked article in the first article re: how to check for existing SSH keys https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys
I am just gonna assume I don't have any
I think they mean "Open your terminal program"
And that's a safe assumption.
In your situation. Plus having a separate key for each thing is better. Then if something is compromised or needs to be deleted, you're not borking multiple things.
so do I need to save the SSH key somewhere?
Yeah, what I linked should explain.
I think a typo.
Because it sounds kinda nonsensical to me.
git is the CLI stuff, and bash is a type of CLI.
yeah it didn't make sense to me, I thought Bash was linux specific? but idk computers
MacOS used to use bash.
I use it on my Mac.
I think it defaults to zsh now though.
hmm so just open a windows command line?
I think so, yes. Oh, you're on Windows.
um
I genuinely have no idea if it works on Windows.
shoot
Try it!
can't (probably) hurt
Also, heads up, food arrives in < 20 minutes, so that -5 is how much longer I'm around.
Yeah give it a name, similar to what the article suggests I think
oops my bad, I had moved off the article let me read more. Thanks for your help, enjoy your meal!
I wouldn't let go of the article until you're done - it's a lot of fiddly steps.
Thanks! 🙂
Turkey, brie and cranberry mayo sandwiches with sweet potato fries. And deep fried cheese curds. And SKOR cheesecake for dessert (SKOR is Canadian Heath bars).
dang, it doesn't show you your password when you type it in or even indicate how long it is
that's some overboard security
Heh, nope. You have to get it right or no go.
should I try to save the "key fingerprint"?
I don't remember 😕
kk thanks
it doesn't say to in the guide so I'm not gonna
hopefully that doesn't bite me
weird, the next step isn't working. I ran ssh-add C:\Users\MyUN/.ssh/id_ed25519 and got "not such file or directory"
Is that what you named your file?
I didn't name it
Here, you had to give it a name, didn't you?
I just hit enter per the guide, it uses the default
I can see the key sitting in the folder rn
oh, is that what the default name was then?
ok hmm
wait
the / are weird for Windows, aren't they?
I'm not sure
I thought Windows liked \
Let me try that
I think that's the one Windows likes...
otherwise you have to use escape characters or some such....
OK, need to go prep for food. Good luck!
thanks, enjoy!
hmm, I fixed the slashes to ssh-add C:\Users\MyUN\.ssh\id_ed25519 and still got the same Error connecting to agent: No such file or directory
it seems that the "windows" instructions use non-windows commands >.< e.g. eval
\
/
Oh wow.
I think that often gets handled correctly yeah. Not sure at what level of tooling the correction gets applied but it might be close to universal
makes sense
Any idea why it's saying the file/directory are not there? I can visit the file and see it just fine
So the key generator is saying it doesn't have permission to write the file?
On linux, IIRC, the ssh client will not let you use a key unless it is read-only
it's saying Error connecting to agent: No such file or directory
permission mask 400
on Windows, afaik there is not such a notion of permission, so idk
hm
also, are you sure the "no such file" is referring to the key file? sounds lke it's looking for ssh-agent and might just be saying it's not running
yeah I'm totally unsure
the weird thing is the guide has linux commands, e.g. eval but i'm in the windows section
oh yeah I remember ssh-agent (which I don't use) having some step where you eval the output of another command
that increases my confidence in the guess that the error you saw means "I'm looking for ssh-agent but it's not running"
those microsoft instructions seem to explain how to start ssh-agent
it's very frustrating. Github is worth millions if not billions. They have to serve enough windows users for it to be worth it to write a working guide. But they seemingly haven't bothered
let me try
also, I think you can use git SSH keys without ssh-agent.
on linux you would do something like
GIT_SSH_COMMAND='ssh -i /path/to/id_ed25519' git push
the low-effort windows version of this might be as described in this answer
https://serverfault.com/a/198709
so from your first link, would you set up OpenSSH first?
on second look, the MS guide looks like not the right page, since it's about running an SSH server, rather than client
did you run
net start ssh-agent
as that article says?
caveat, I've never done any of this on windows, and for all I know, the windows git installer may also install openssh or something like that.
let me try that, sorry I'm also tasked with installing smoke monitors but can only run the drill when my boss is on hold on the phone lol
my job is weird
that'd be the first time I've heard of a situation where holding on the phone is safety-critical
it's more "audible conversation" critical
I got the error The service could not be started, either because it is disabled or because it has no enabled devices associated with it
looks at page title which contains the phrase "IoT" oh no...
my gosh, they have a "install SSH for X purpose" page for so many different values of X.
https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/factoryos/connect-using-ssh?view=windows-11
it would be great if they simply explained how to use some particular SSH client in general.
maybe Microsoft are not the right people to be asking.
this seems to be for FactoryOS? What's that?
No clue
dang. I wonder if github support would be able to fix this. Let me see if they have a chat function
I would at this point look to the git for Windows docs instead of Microsoft
yeah that's where I started
And see if they give an easy way to set the SSH command, analogous to $GIT_SSH_COMMAND on Linux
If there is one, you can set it to 'ssh -i C:\path\to\id_ed25519'
But yeah if you can get a github support rep (though git ≠ github) that's even better
also, ssh -vvv to see what it does exactly...
Hmm
I got a bunch of stuff I don't understand. What am I looking for?
are trailing spaces relevant? I see that it actually says it was saved in C:\Users\me/ .ssh/id_ed25519 and not in C:\Users\me/.ssh/id_ed25519
yes
hm
let me try again before finishing my annoyed support message to github
same error, "Error connecting to agent: No such file or directory"
Fwiw, none of the software components you're trying to set up so far was actually made by github, afaik. But I think you're correct that github aims to provide support on this kind of issue as part of their business model
yeah I figure for us paying for a teams license, we're reasonable to expect some support
Sure. They might not deserve annoyance on the first message though 🙂
I toned it down
I bet they get lots of customers who already tried tons of things. It's understandable
I have been on the receiving end of angry emails about things outside of my control, and I wouldn't want to do that to someone
Being empathic in moments of frustration can be hard... I'm definitely not perfect in that regard but I try and glad you do too
Looks to me like I just copied my public key to my local clipboard, and pasted it into github.com under 'settings'.
(In Linux, as always)
$ ssh-agent
SSH_AUTH_SOCK=<foo>
SSH_AGENT_PID=<foo>
paste those into the shell where ssh-agent was invoked. Paste the entire line (both lines) verbatim.
$ ssh-add .ssh/id_rsa
That one prompts for the password. In that one instance of the shell (only) you won't have to keep typing in the password associated with that key pair (id_rsa.pub, id_rsa).
I'm on windows unfortunately and can't reasonably change OS
This looks too far out of date, but it is a vocabulary and concept builder:
https://stackoverflow.com/questions/34638462/using-git-with-ssh-agent-on-windows
The ssh-agenttag seems to contain useful entries.
If you do everything on the Raspberry Pi (under Raspbian or Raspberry Pi OS) that'd give a good model to work from.
Raspbian is basically Debian.
git is native to Linux as it was designed by the Linux kernel developer (Linus Torvalds).
'the' Git book is here:
One mention of Windows stuff here:
https://git-scm.com/book/en/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-PowerShell
thx!
;)
I originally had code in two files, meant to run on different processes on my pi, but I managed to get the simpler of the two combined into the more complex one. Should I leave the old code in my repo or delete it?
That's the great thing about version control. You can always go back and view it in the past. So feel free to delete it.
People talk about being a hoarder as if it's a bad thing...
I have no clue how anyone presses backspace with peace of mind unless they're using version control
@full steeple If you learn how to do a Release, it locks in the old stuff to a 'permanent' form without an action similar to forking into another subdirectory.
I do that when a project is working well but isn't complete (or is suffering from freeping creaturism. ;)
Been using this guide for a few years now:
I usually stop when Step 16 is completed; Step 17 is just verification, and I do it consistently enough I don't have to do Step 17 (or read any further).
removed many messages; transcript before the deletes, just below.
_that got a bit too spammy; here's the transcript:
has anyone used Github LFS (Large File Storage)? Normal github is balking at uploading a 1.3GB shrunk raspberry pi image.
I could use my org's google drive but I'd rather have all files in the same place
I am confused by this step. I thought bash was not a windows thing
do they just mean a windows command prompt? I have found many of their guides say to use bash on windows which really throws me off since I was under the impression that bash was not a windows thing
Is git bash a program that comes with the thing you installed in the previous step?
I don't think so? It doesn't make any mention of it
wait it's probably wherever you can access git from the command line.
In Windows.
Perhaps it's expecting an installation of Windows Subsystem for Linux (WSL) which provides an Ubuntu terminal window as a Windows application. If you're already a Linux user and either using Windows (or in my case, forced to use Windows) you get a normal Linux command line, bash or whichever shell you want. The filesystems aren't compatible between Windows and WSL which is screwy but it's certainly an easy way to have a git CLI on Windows.
Hmm I'll just use Google drive for now, too busy with other stuff. I'll look into ichiro's idea later
oh interesting, thank you! I'll check that out when I have more time.
Is this similar to the WSL that Ichiro mentioned?
No, it seems it's an emulator for the portions of bash you need for git, whereas WSL is actually a full Ubuntu image running on Windows as a terminal application.
Well, I have no experience with the git bash thing, but WSL is basically a terminal window that is actually Ubuntu, from which you can install git and use it on the command line. You by default have bash as your shell but could use csh or tcsh or zsh if you like. The screwy part is that the Ubuntu filesystem and the Windows filesystem are entirely incompatible, such that you should never modify files or directories on the Windows filesystem from WSL, or vice versa. If you're comfortable with that limitation and already have Linux command line experience I'd definitely go with that over a git bash thing. But if you only plan to do git then perhaps it'd be better. Certainly a smaller install, as WSL is an entire Ubuntu installation on your hard drive.
I did a whole Java project on WSL as that was all I had available to me as a Linux user forced to use a Windows machine. And given I'm comfortable on the command line (prefer it to UIs, generally) that worked out fine. You can install any command line application via standards like "sudo apt install foo". I believe later versions of WSL may even support X (the windowing part of Linux) but I have no experience with that. I finally got a proper Linux desktop and could stop using WSL as a stop-gap.
WSL2 is supposed to support Linux GUI applications, but I had already moved back to a linux main system for work and was just using a Windows VM for the few things I needed windows for, and WSL2 doesn't work with every hypervisor (as it's VM in a VM)
Yes, and if I remember right it's also basically impossible to do anything real with Docker on WSL.
Docker Desktop is a Windows application but the Ubuntu kernel in WSL doesn't know that it's running in Windows and there's no binding between them. (this all from memory of a few years ago)
I personally dislike docker for a multitude of reasons, so I use it as little as possible and wouldn't know.
For professional reasons I remain agnostic as Docker is one of the tools we use. Our apps are packaged and deployed as Docker images.
Well, drifting off topic, I'm working on a bunch of different Kubernetes Clusters in azure (aks), and using ArgoCD to manage the containers the engineering teams build. That's as close to docker as I want to get.
I've been using WSL2 with QTCreator for an embedded project. Had to set up an xrdp session but it works fine.
I'm trying to use Git LFS, I downloaded and installed it (it got at least as far as the license acceptance) but git doesn't work as a command in my terminal window (Windows 10)
how can I check if it was actually installed?
opening the .exe just prompts a window to use the terminal which doesn't work
Did you install Git Bash?
I installed what they said to install
My PATH contains this by the way
Open a new terminal window
and do echo %PATH% in cmd or echo $Env:PATH in Powershell
now the eternal question: which editor to make default
I think I'll go with n++, I'm familiar with it
I'm here now: Do I need to move to the repository in question some how?
I've never used git LFS (which as I understand it is a third-party extension, not ordinary git), but that git lfs track command looks like it will search up the directory tree (starting from the working directory of your shell session) until it finds a git repo and apply the command there. That is what the core git commands (add, commit, etc.) do.
For ordinary git commands (and probably this one too), the choice of git repo at which to apply the command can be explicitly supplied/overridden with the -C option.
ok, here's a possibly trivial question from a git-newbie: I have forked circuitpython on github and cloned it to my pc in WSL. I set things up according to the instructions and I'm able to build circuitpython. I'm keeping my fork up to date using the 'fetch upstream' button in github and 'git pull --all' in my local repo. That worked fine for a while. Github currently says my main branch is 13 commits ahead (because I added some of my own board definitions) and none behind adafruit:main. Still, my fork is lacking the latest tags (7.1.0-beta.0 and 7.1.0.beta.1) and when I build, I only get the latest 7.0.0 version, not the 7.1.0.beta.1. What am I missing?
great, I overlooked the pinned messages. Thanks for the hint 🙂
how to learn git?
there are some links pinned in here
click on the channel name, and then on pins
is there a way to check how fast a push is uploading? I'm using Github LFS (Large File Storage) and I've been "uploading" for over 2 hours. It's a big file to be sure, but I think it may be hung. If it is hung, what can I do?
Seems like github is giving a number of people issues. I'll chalk it up to that
A lot of cloud services have struggled this week, too
Not sure where this question would go but trying to figure out what CAD model would be close to what the SCD-40/SCD-41 (CO2 sensor) is based on .. seems like a common sensor board base which is perfectly square PCB. Trying to bring in the various components into my 3d modeling to work out design
ask this q in #help-with-hw-design and I will give an answer there for you and for others
ok, i proactively answered there
Hm, there's something weird going on in my Github folder. I renamed a repo to MyNewRepoName, and it shows up that way in Github Desktop's viewer, but when I go to my actual Github folder it's still MyOldRepoName
And if I add files to the folder name MyOldRepoName, they show up in Github desktop under MyNewRepoName. Super odd
Git doesn't care what the name of the folder containing the repo is. You can rename it at will... and it will have no effect on the repo. The Project name in github, while initially taken from the directory name (or vice-versa) isn't kept in sync.
You can, I believe, rename it within GitHub. If you do, though, you'll have to reestablish the remote linkage in your repo on your disk.
Agreed that one should do this 🙂 though last I checked, GitHub will redirect access to the old repo automagically to its new location, along with a warning message saying to update your remote URI to the new place, though the redirect i.m.e. lasted at least many months if not indefinitely
cool - didn't know they did that!
Does the Adafruit github take pull requests? Found a typo in an Adafruit repo and submitted the PR, but not sure if anyone is monitoring for new PR's
We do! There are many, though, and sometimes things get missed. What repo?
Ah cool, it's actually your repo, haha! Here you go: https://github.com/adafruit/Adafruit-Wii-Nunchuck-Breakout-Adapter-PCB
The PCB repos aren't on our radar as much as others, so this definitely would have been missed. Thanks!
No problem, glad I asked!
Oh! It looks like I'm wrong on that. Ladyada already notice it and tagged one of our folks to take a look. He'll be able to verify it better than I can - I don't think I have the board. He does.
So please be patient and we'll get to it soon!
Sounds great, thanks for your help!
Argh! I totally messed up my git commit and can't figure out how to get it back. https://github.com/adafruit/circuitpython/pull/5954/files
Maybe this helps: https://ohshitgit.com/ ;)
I accidentally commited with git commit -am and all files got committed. I reverted the commit and then lost all my changes. I tried again and made it worse.
bookmarked!
I am still learning git, so I always copy my project before commiting 🤣
Too git-frustrated now, will try again in the am....
If I want to use interact with my Github repos using my pi 3 A+ which really struggles to run programs of any complexity, I'm going to need to git gud at the command line, right?
Most likely, yes.
shucks
When it comes down to it, there's a basic set of commands you'll use repeatedly, and you'll get them down quickly once you use them a bit.
When you have to do a complicated rebase, that's a different story. Heh.
rebase -i
Also check out the gh command line tool from GitHub to use in conjunction with git for dealing with GitHub and so on.
Minor wrinkle is that I want to setup access to a repo that's inside an organization so the repo is say MyCompany/CurrentProject on Github
git doesn't really care
I'm starting here https://projects.raspberrypi.org/en/projects/getting-started-with-git/4
I'm thinking
git config --global user.name "My Name"
git config --global user.email "MyEmail@MyCompany.com
git config --global core.editor geany
is what I want. I don't love Geany but it'll have to do
vim for life
@full steeple This guide is based entirely on my workflow. It doesn't include git config. The "Grab Your Fork" through "Status, Add, Commit, Push" is what would apply to you right now, I think. Might be helpful, might be useless to you. But it's what I have. https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github
As long as it has dark mode built in and syntax highlighting I'm happy
vim is super configurable.
just wait until you try to exit it ;-)
I am still SUPER bad with it, but it's what shows up when git wants to do things.
I was joking, while vim is an excellent code editor, I wouldn't force people to learn it on top of whatever else they are learning
Appreciated 🙂
@sturdy talon you can configure it to use nano or mcedit or whatever
I use it as my little "learning vim" opportunity.
that's commendable
Also my bash uses vim commands. I know... some.
Oh this is more than I want to chew on right now
Looks cool but I'm on a bit of a deadline
try mcedit
the quit command didn't work lol
from midnightcommander
it looks like the editor in norton commander, if you remember that
shift+z+z 😄
blue background, function keys on the bottom
So is VIM particularly powerful or do people use it to flex?
yeah, vim is there together with emacs
vim is super extensible, but people do use it to flex too.
You can do a ton with vim once you have it down.
one of the ethernal holy wars
But it's getting there.
it's not an editor, it's a lifestyle
Maybe I'll use it for my next personal project
sudo apt-get install mc seem right for Midnight Commander?
yup
I'm just looking for an easy to use text editor to pair with git
mcedit, nano, pico -- are the popular ones
lol, it's warning my of 7 MB of disk space used
well, midnight commander is a clone of norton commander
it comes with a lot of tools
mcedit is just one of them
I meant that that's not much
it's a whole file manager
ahhh so I'm kinda looking for something that isn't run in the command line
it was much for me, back when I had 360kB disquettes
I really wanted Notepad++ but it doesn't exist for Linux, Sublime Text doesn't exist for my pi
geany will have to do, I'll see if I can find a dark mode
So the guide I'm following is great if you want to create a repo on your machine and push it to github, what if you want to clone a repo onto your machine?
git clone -o repo_user_id repo_url
ooooh
I always change the remote name so I don't get confused by origin
what is repo_user_id? my github name?
If it's your repo, yes.
For example, here is me cloning Adafruit's CircuitPython repo: git clone -o adafruit git@github.com:adafruit/circuitpython.git
So if I cloned my fork of it, it would be git clone -o kattni git@github.com:kattni/circuitpython.git
Your repo_url may be HTTPS.
what does this mean?
Same format for the command though.
Ok, so when you clone without setting a name for the remote, it names them all origin.
Or names the first one origin rather.
So, it's unclear what's what when you're pushing back to it if there are multiple remotes involved (such as when you fork)
a single repository can have more than one addresses, those are called remotes
To be clear, this is my workflow. It's not necessary for git to work.
so you can have for instance both adafruit's and kattni's forks in the same repository on your disk
^^
this is especially useful if you need to cherry-pick from one to the other
That way I can work on my fork, but PR back to Adafruit, while staying up to date with Adafruit's repo.
interesting OK
when you push, it will by default push to origin, unless you tell it to push to some other remote
I'm realizing I want to make a separate repo for my code alone so that way if someone gets access to this pi, I only lose the code and not my EDA/CAD designs
you won't lose anything, you will have it all on github too
at least everything you pushed
no but someone could steal our IP
the code I'm willing to risk because it took me a day to write, and isn't complex
But the EDA/CAD took work
that is usually not a problem with the open source projects like circuitpython
yeah I'm using only a single CP lib, the rest is CPython. I guess I could make mpys but I think the risk of losing the code is relatively low, I have a username/password for SSH and I'll be disabling wifi.
"losing"
more like unintentionally publishing
I'm mostly concerned about someone SSHing or gaining physical access to the pi that's running my code. I think it's unlikely but it could still happen
make sure your github repo is not public, then
Once someone has physical access to your machine, you have a whole host of other issues.
Not much to be done at that point.
is the pi exposed to the internet?
yeah, with physical access they can just take the sd card and copy it
Yeah it would be relatively trivial for a bad actor to steal the SD card so it's best to keep as little on there as possible.
I would highly recommend not having it exposed to the internet, if you can
it's not
if you must ssh to it from outside, at the least use a non-standard port
I don't SSH into them
Long term I'd like to set up an automated deployment system but that's a ways down the road.
So I guess I can just create my Code Only repo here on my pi. On my windows machine I used github desktop and when I set it up it created a GitHub folder. Do I need to do that or will it happen automatically when I make my first repo on the pi?
git and GitHub are two separate creatures. Creating a git repo locally does nothing to GitHub.
You will need to manually create the repo on GitHub. Then when you add the remote or clone it, it will know what to talk to.
Ahhh ok
I knew they were separate I just assumed some magic happened in between
Nope! If you clone then magic sort of happens because the clone creates the repo locally.
But if you git init a repo locally, you have to git remote add user_id repo_url to get them to play nice.
So the repo I want to clone is under the org MyCompany, so would it be
git clone -o MyCompany URL?
or
git clone -o MyCompany/MyRepoName URL?
cool thanks, I'll give it a shot
Also I did a dumb thing and named our overall Github Org badly. I was warned by Github against renaming an organization, is it a bad idea? Or best done before I have too much stuff stored?
I got a permission denied error
Um... I think it's a bigger deal if it's a really public org or something... but I would google why GitHub is warning against renaming the org. I've never done that so I'm not sure.
Hmm, is your git configured with the proper credentials? I use SSH, which involves a key and other setup. So I don't remember what's needed for HTTPS.... I think it's supposed to ask you for a username and password...
oooh must not be, I was expecting a username/password request
ooh that's right, GitHub got rid of Username/Password I think
Gah their official docs refer to using gh, not git so I assume things are different
gh is also really useful.
Oh hmm.
Well, it's possible to do with git though...
But I think you need to generate an API key on GitHub, iirc...
ok so git clone url resulted in a request for username
ah password auth really is gone
They shouldn't offer to take my UN/PW if they aren't going to do anything with it
Oof.
Good luck with this... once you're set up, things will be smoother. But sometimes setup is tweaky. I have to head out.
using ssh without a password (per-shell instance only).
Np thanks for your help
Can I safely delete a private key and store it somewhere more secure? My pi is not going to be that secure
should I
let me take a quick look.
it's basically encoded similarly to base64 or uuencode
that's the storage format on your storage medium (SD card probably).
You could ssh into the Pi.
Then write that file each time you need it.
Permissions are -rw------- for ~/.ssh/id_rsa
You can truncate it easily enough; though that's maybe not all that secure.
I don't worry about that stuff so I don't know the proper way to expunge it.
I think rsync over ssh might work for one-off installs of that file.
That probably relies on ~/.ssh/known_hosts
(This stuff is covered on DigitalOcean in light tutorials; I usually go there when I need to revisit it)
I'm mostly concerned about someone taking the SD card out of the pi and gaining access to our Github
what exactly are you considering doing?
if you delete the key, then you can't use it...?
copy then delete
Keep it somewhere more secure where physical access to the data is harder to achieve
I suppose with TinyCore (they might have an RPi3 or RPi4 port!) .. you could just load it all into RAM.
but you want to be able to push to GH from the pi, right?
can't I use the public key?
oh duh
no you can't
Sigh I guess I'll have to scrub the pi before I deploy it
istr there's a reason why the private key requires a password used with it.
SSH agent forwarding can be used to make deploying to a server simple. It allows you to use your local SSH keys instead of leaving keys (without passphrases!) sitting on your server.
you'd SSH into the pi from a machine that has the keys (your laptop or whatever), and can use the laptop's credentials (forwarded over the SSH link by this doohickey, AIUI) to push to GH from the Pi
ahh ok
Hmmm, I haven't yet tried SSHing into the pi
I guess I might as well try it and see what happens. What should I do with the ssh keys I generated?
how did you generate them? ssh-keygen on your laptop?
no, on the pi
well, if you don't trust the pi to be secure, then there isn't much use for the keys sitting on it, eh?
I don't think they are keys to anything atm
yeah, and if the pi is not considered secure, they should never be the keys to anything
I'd just delete them
just have a strong password on SSH into the pi?
all of this was in service of me trying to clone a repo onto my pi
is the repo secret?
yup
and you want to clone it onto an insecure device
The repo is just the python code for this project, which is insecure on the device anyways
Unavoidable
ok then, I don't understand the threat model or the security requirements of the project
There isn't any sensitive company data on the pi, just code that if it's stolen it's kind of whatever. I wrote it in a day and any competent programmer could in likely less time. What I'm concerned about is someone stealing the SD card and gaining access to our company's Github repos
ok then SSH agent forwarding sounsd like a good fit
sigh, somehow I'm logged into Github in the browser on this machine, but the pi doesn't quite have the oomph to open the dialog box to log out
indeed
is your concern that the thief would also get other repos that aren't cloned to it?
Yeah, or through some mechanism I'm ignorant of
if so, you could put deploy keys for specific repos on the pi, and the thief would have access only to those repos
and, if they stole the keys without your knowledge (copied them off the SD card and you never knew), then they would have access to future changes to the repos for which they have deploy keys, until you find out and revoke the deploy keys
so, SSH agent forwarding might be best.
a really dedicated thief who wanted to get your company's stuff could probably hijack the pi and set up some kind of man in the middle attack, but like, that would be pretty sophisticated
yeah I think so. The pi won't be in range of wifi when deployed unfortunately so I may have to set it up with our wifi hotspot in advance
TBH, if they want to go that far, they have poor priorities. We're not doing anything terribly interesting
I ain't curin' cancer
yeah, that's kind of why I didn't fully undesrtand your threat model
I'm just trying to develop good habits
and if something does happen I want to be able to say what I considered and what I dismissed.
Rather than be caught with my pants down
I don't understand the relevance of this part -- the pi will need a network to access the remote no matter what
ah
I'm developing on the pi, but when it's ready to deploy, it will be somewhere without wifi
while I'm developing I want to be able to push to the repo
yeah that's fine
this "can't log out of github" thing is a big problem
I didn't know that was a thing.
Apparently git integration into gee-whiz stuff has a cost. ;)
Hi All, sorry for what is probably a dumb question, but I am a total noob to using git. I submitted a pull request and one of the CI checks failed, and I cant figure out what the problem is.
is the log of the failure.
Is there documentation somewhere on what these errors mean?
Your code needs reformatting by the black formatter. See this guide: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library and especially check out the pages on "Check your code with pre-commit", "Run Pylint", and "Black".
Thanks for the pointer! I installed black and reformatted the file.
Do you guys think just getting used to a Git integration is a bad idea?
Recently I've been forcing myself to live in Git Bash
And I just find my work somewhat more versatile, it's just off my comfort zone, though it keeps getting more comfortable
I mean, you'll get a biased answer from a #help-with-git channel, of course, but it's a definitely useful as a job skill if nothing else, and some sort of version control is generally valuable for saving yourself time and frustration in software development.
I meant the distinction between just using IDE Git GUIs vs using Git Bash itself
Yeah, version control is great
But I've gotten the impression that raw Git Bash is rather efficient to become comfortable with, vs IDE GUIs
Since they're all implemented on wrapped Git Bash principles, so just understanding Git at its core is better in the end, right?
Ah, gotcha. Yeah, that would be more of a general "command line versus IDE" preference, so I'll refrain from entering that holy war, heh heh, since I use both.
It seems like a generational gap, doesn't it
Which is understandable. Much has changed, and many people don't like too much change
@fierce gate git has a relatively terrible CLI: consider how many commands give you hints about what to type next. Nevertheless, it is useful to understand what git is actually doing. I read the Git book https://git-scm.com/book/en/v2 a long time ago and it was quite illuminating about what commits and branches really were, etc.
I do almost all of my Git work from the command line. I rarely use the Git extension for VSCode, but it can be pretty helpful when working through conflicts.
I do a lot of redundant typing on the CLI to use git. ;)
I use a hard disk repository called localorigin for all projects, in addition to the regular remote, origin.
I use the seven-digit hex commit representation of 'git branch -avv' to checkpoint work often, in new branches named for that commit shred - only in remote: localorigin.
Generally when I'm feeing good about the work - so those represent safe places to branch from, if and when.
I keep the output of 'git branch' (which does not point to a remote) quite brief; usually five entries or less.
'git branch -D <repos>' to get rid of stale ones, after first pushing to the 'localorigin' repository (on-disk).
🔸
I use a simple recipe to make copies of files, complete with their edit histories, incrementing the directory name from '<foo>-aa' to '<foo>-bb' &c.
The recipe iterates 'git mv' as the core of how it works.
Move from old to new; commit, restore what was moved, merge. Uses two branches, one of which gets deleted after the merge. Result is two copies of the work, the copy in a new directory.
hey has anyone tried to git clone rpi-rgb-led-matrix repository and then pip install the python binding?
I'm not sure if this is a git question or more of a terminal question but git is the only thing I've noticed it happening with so here goes:
Does anyone know what could cause git submodule foreach "git grep -n something&true" to cause the terminal that it runs inside of to be broken. After running this (in the CircuitPython library bundle if that matters) My terminal no longer shows anything I type at the prompt.
But it is still receiving the things I type i.e. if I type ls and press enter. I don't see "ls" in the prompt but I do see the output from that command.
I have used this before to search all of the libraries for things and I don't recall running into this issue. I tried in multiple different terminal programs and all behave the same. I also have a terminal prompt thingy called starship and I tested with it disabled to rule it out as the issue and I get the same result.
Is anyone else able to try running a submodule foreach git grep command like this and let me know if you see the same issue after it executes?
Did you try restarting your terminal? Or your terminal environment? I imagine so, but figured I'd ask anyway.
running it now.
No issue running it here.
Yep, I've restarted a few times inside of pycharm and restarted once outside pycharm in gnome-terminal. After restarting it works normally (I do see things as I type) but if I run a similar command again I get back into the same state.
Okay thank you! I'll mess with it later, it's not too big of a hindrance because it's easy to just launch a new one. I am planning to show people this trick while talking about the bundle but would shy away from it if it is broken/confusing across the board. Probably just something wonky in my environment. I'll try updating some things later and maybe it'll sort itself out.
You're welcome!
When it's in that state, try just tapping [enter], or issuing the "reset" or "clear" command and see if that fixes it. Especially with the "reset" command, if that fixes it, that means your git command is doing something funky - including probably not printing/echoing a newline after the input. I get similar behavior with Curl sometimes. My work-around is generally to just hit the [enter] key afterwards, but if I accidentally run "cat" on a binary file, I often need to use "reset".
Thank you! reset does seem to fix it. enter by itself does "run nothing" and make a new prompt, but remains in the state where what I am typing is not shown.
Gotcha, that sounds to me like either some binary data, or perhaps some characters outside the terminal character set, and likely not strictly git-specific if I had to guess.
Good to know, thank you.
@pallid thicket Yeah, there are special characters that can mess with the terminal state:
https://en.m.wikipedia.org/wiki/ANSI_escape_code
Maybe git grep found a line in that particular repo that matched your query and also contained some wonky escape codes. In my book, that would not be a bug in anything, it would be correct behavior.
ANSI escape sequences are a standard for in-band signaling to control cursor location, color, font styling, and other options on video text terminals and terminal emulators. Certain sequences of bytes, most starting with an ASCII escape character and a bracket character, are embedded into text. The terminal interprets these sequences as command...
I would expect redirecting grep output to a file (git grep foo > myfile.txt), then opening the file in a pager or editor that doesn't trip on weird bytes, to be one possible workaround. I think almost any viewer (e.g., less) will work, as long as you don't specifically tell it to do things with escape sequences (e.g., less -R).
@pallid thicket try “-l” (that’s an el not a one) instead of “-n”, to see just a list of matching files because compiled files or non-text files don’t really have lines. “.pyc” files are compiled python for example.
stty sane can rescue a messed up terminal sometimes.
Maybe run a file through the strings utility before going to grep? So it keeps only printables. not sure how you interact with git grep there though.
ag (the Silver Searcher) highlights its output; newer compiler toolchains do so as well.
In each case, just pipeline through /usr/bin/cat to catch that stuff.
$ ag sizeof | cat
$ ag sizeof | cat -n
reset is useful, as mentioned.
For ssh, to one server where it's a problem, I use:
$ stty -isig
Also the terminal program itself may have a protective switch you can use.
pipelining through /usr/bin/cat is my usual strategy, though.
Can anyone recommend what GUI client I should install on my windows PC for GitHub use
Github desktop isn't an option?
I'll try that. thanks
np
@winter sierra It looks to me like it's thinking that all or most of the files in the whole repo were modified. I'm not sure why it would be seeing changes on most of them.
Honestly I am not the best with git outside of the specific workflow that I've gotten into for library PRs. My ability to troubleshoot git is limited. So usually when I end up in a weird state and am unable to figure out exactly why or how to get back I end up just making a whole seperate new clone and starting fresh. It's probably possible to recover from the state you're in but I'm probably not able to help get it back all the way...
If you're willing / interested to start a fresh one though I can try to walk you through from there.
Maybe the best thing to do is to delete the whole fork and create a new one. It's just these five examples that I created
It might have been possible to keep the fork. But deleting will end up being easier in this case I think.
your last text part between () I don't understand. Can you rephrase pse
@winter sierra Ah, one thing I noticed is that your fork is created from my fork instead of from the Adafruit one. So actually I do think it'll be easier to delete the fork and make a new one starting from Adafruit.