Let's test the notes with some icebreakers! :icecream:
What was the last animal you saw?
Which path did you you use yesterday to interact with Git?
How do you set up the webpages for the tutorials/documentation at https://coderefinery.github.io/?
Is there anything you want us to repeat today?
I did not really understand why I need tags
Where is the instructions for the first exercise of today?
Is there any difference between using 'git clone' versus downloading the ZIP archive?
git clone
links it to the Github repo, which means you can get updates and merge with your changes easily.git clone
since it's as easy and I can get future updates if needed (and see any modifications I made)https://coderefinery.github.io/git-intro/local-workflow/
Step (3) Creating branches locally = for this one do we need to be in the same directory of recipe-book?
🚨 In step (3), I think the arrow in the screenshot of the solution for VS code is pointing at the wrong dots, it should be the three dots next to "Changes", not the three dots next to "source control".
What is the difference between git switch
and git checkout
?
git checkout
was the original one and did several very different things (changed files, changed branches)git switch
was added a few years ago and only changes branches. Most computers updated in the last 5 years should have git switch
now.How do you know which branch you are on when working on the command line?
git status
- always a good thing to run, often! +1git branch
it will add an asterix next to the branch nameIs it possible to make git use, e.g. vim
instead of GNU Nano
for merge messages and stuff? I always have to look up how to quit, because I am not used to GNU Nano
.
git editor vim
(or whatever) you will probably see how to do it very easily.git config --global core.editor "vim"
(or any other of your choosing)Only for the merge or for everything?
git log
I can easily quit, because it is similar to vim
but the editor always gets me :DIn step (4), I dont see + sign to add the file for the next commit (in VS Code).
Do we have to cd into the cloned directory before creating the branch?
I did everything like in the walk through but when i want to merge the two branches the new files i added in the new branch dont show up in my main branch. i dont understand why?
git log --oneline --all --graph --decorate
tells us some of what's going on (but, we only learn about this in the next hour)Can GitHub Desktop also be used to perform these steps?
What is this page, where presenter is pasting the code from github? Where the presenter is working right now....is it some word document, it cannt be. Ti AM REFERRING TO THE LIVE SESSION ONGOING. No, i mean the presenter who is speaking and presenting and writing the commands. thanks
git graph
configured in this (optional) part of the git setupThe output from git commands is shown with less instead of printed to the terminal, even if the output is really short (e.g. two lines from git branch
)
git config --global core.pager "less -FX"
: less
is the usual default pager, and the added -FX
means that it will just print the contents if it's short (instead of entering the "interactive" mode with less than one page of content to view)So we have to use 'git add' even on files in the repo we only modify and do not create, in order to commit those changes to the repo?
git commit -a
to commit every modified (but not new) file at once.I fell from the train already +1 +1
Assuming I have VSCode installed. Is there a wiki page/youtube for setting up/linking my github with it. I have performed the exercise via the command line already but it will be good to know VScode as well especially since it serves as a good editor. Thanks. The instructions send from https://coderefinery.github.io/installation/ only sends to me to install github but not the getting started with GitHub, that's why I asked.
When it came time to merge the another-recipe branch with the main branch, I was taken to a vi session with a file saying I had to add some comments. It was annoying b/c I am not comfortable with vi. Will this always happen with merge operations?
I am already strugling with ssh. When I wrote Z:>ssh -T git@github.com I got git@github.com: Permission denied (publickey).
How can i figure it out? I have no idea what to do :D
Can we talk about what HEAD means, and how it relates to origin/HEAD, etc? In the branch list, it shows e.g. remotes/origin/HEAD, remotes/hummus-recipe versus remotes/alex/salad-recipe.
would it be possible to share commands before hand so that one can easily follow you are executing them? It is easy to get lost if you move eyes to another screen just for a second.
A very basic question: does changing the directory locally using 'cd' on the command line also change the branch?
OK but then I don't understand the connection between a local directory and the local clone
I tried configuring git and all that, but when I'm trying to git switch --create another-recipe main OR master, I have fatal errors in both cases fatal: invalid reference: master. Why this is?
main
and not master
, so only the first will work.git branch --all
. Do you see main
or master
?Just to be sure. Does a commit only affect one file? Or can it affect multiple files?
git add
multiple files if you want, but you can also just add one even if you have modified multiple fileshttps://coderefinery.github.io/git-intro/archaeology/
I do not understand what the output from git grep is supposed to be. When I run it, it gives nothing
git grep
. In this exercise, git grep "Logic error in degree_correlation"
what do stage and unstage do in VSC?
git commit
. Anything not staged (or unstaged after initially staging if you realize that you didn't want to include some change after all) will not be included in the commit.Where did I get the individual commit hash again (for git show HASH) using either the web interface or command line?
git log
(and other incarnations), or git blame
(a less nicely named version of git annotate
).git annotate <file>
where <file>
should be replaced by the name of the file that contains "Logic...", so git annotate networkx/algorithms/threshold.py
. Look for the line that contains "Logic error...". At the left of it you will see the hash of the commit that last modified that particular line.The latest commit hash looks like '90544b4fa5' for me and not '90544b4fa'
A comment on bisect: I usually have tests, so I don't need it, BUT it happens from time to time that my tests take very long to run, so I do not run them for all the commits I do. In that case, I might run them only once in a while, and then, if an error is found, I use bisect to find the commit where I introduced the bug.
How do run a specific commit. When i run bisect it tells me that it got to commit 251, how do i tell python that I want to run commit 251 to check whether that is the offending one? and then go back to bisect to see whether the error was introduced before?
git switch --create good-commit 251
, which will "switch" to that commit and also create a branch named 'good-commit' there. You can also use, if you do not want to create a branch, another command - git checkout 251
- but it is a weird command.git switch --create bad-commit 251
it gives me fatal: invalid reference: 251
git bisect bad master Bisecting: 250 revisions left to test after this (roughly 8 steps) [5c6fb09b319ae1f2e09933afce65e825d8c72c77] commit number 251
251
here is the beginning of a commit hash that you found at some point, for example with git log -n 1
sorry no! git log --oneline | tail -n 1
(this gives you the first commit in the history, while git log -n 1
gives you only the most recent commit).f0ea9
(the other one 25b6
is the last, bad commit).Is it considered bad practice to commit in-progress, untested changes instead of small, tested ones, when thinking about keeping past versions working?
In step (2) of the exercise, when I run git annotate networkx/algorithms/threshold.py, I get a lot of output in the command line and I don't know how to enter the next command. The "$ git" does not appear, only ":".
How can I compare the graph locally and on GitHub by VSC?
What do we mean by remote branch? There is also something called origin in the VSC. Does it mean the original repository we cloned?
Is there a way to see on the command window wich branches there are.
git branch
and it will show the branch you are on.git branch --all
what are we doing after lunch in todays workshop?
Anyone else had issues setting up VS code?
These 2 links are some helpful videos (from the CodeRefinery youtube page) I used to set up Git and SHH keys on my local machine's command line. Git Configuration -- https://www.youtube.com/watch?v=WdDTp8NeHBs Setting up SSH keys -- https://www.youtube.com/watch?v=XCDg1mtaA5I
What Extensions are recommended for visualization in VS Code? So far, I have been using "GitLens" and "Compare Folders".
Super Mario Brothers music??
https://coderefinery.github.io/git-intro/sharing/
Problem in command line version: remote: Support for password authentication was removed on August 13, 2021.
ssh
authentication.remote add origin
command), you need to choose 'ssh' instead of 'https'. This requires to have your ssh keys set up, though.Why do I need to manually create a repository on github instead of just pushing my new local repository directly?
git push
cannot automatically create a repository on GitHub for you. At least not yet, maybe they'll introduce it as a feature at some point.git remote add origin git@github.com/myuser/nonexistent-repo
and then start pushing, what should the repository's configuration be like: should it e.g. be public or private?
In command line, I get the following error message when I try to push my repository.
git remote --verbose
, you should be able to see soemthing like:origin git@github.com:mygithubusername/myproject.git (fetch)
origin git@github.com:mygithubusername/myproject.git (push)
git remote add origin
which initialy returned me an error. Now it works, thanks.
How can I delete a repo locally? I would like to clone it again using ssh and not https.
rm -rf <directory-containing-repository>
, but be careful with this message! But you can also change the remote url using the command git remote set-url origin <the-ssh-url-instead-of-the-https-one>
.
After trying VSCode for this exercise, I feel like I may not go back to command line very often as VSCode makes life easier. What do you think of this? +1
Why do I need to set git branch -M main
before I push to the host? -M
is supposed to rename a branch even if target exists, but I don't understand why it is necessary at this point.
git init -b main
, so it was main
main
even if some previous steps were missed, so instructions would work for everyone. (if it's already called main
then nothing happens).
master
as their default branch name would have needed that step.After moving a file to a newly created directory in my repo, it seems I may have lost any change tracking on that file. It shows only last commit after I moved it into the directory
git log <name of the file>
?mv
from command line) and edit the file: then git might think that you removed one file and added a new one that just happens to resemble the old one. One way to avoid this is to do the mv
, commit, and then edit. An even better option is to move/rename the file using git mv
. That lets git know that despite the new name, it's still the same file, and git can preserve the history even if you edit it heavily while renaming.Hi, earlier i asked the question about the use of editor but did not undertood the response. I think someon has deleted the question now. Could you talk abou the editor, which editor you use/recommend?) I am referring to the editor where presenter was writing her code, in the session before lunch. I am not sure if editor is the right word for that...
git
asks you to enter/edit something (like a commit message). You can configure what editor pops up in those cases (it can be your main one, or a different one)git
in the command line, because that is, how I started. So you see: It really depends on what your preference is.Does the synchronize button in VSCode mean the same as push on the terminal?
Can you explain the use of the label 'origin' in the repository structure?
Also, when you go to GitHub to create the remote repository matching your local one, does the name have to be the same (as the directory on your local machine?
In Exercise, for VSCode path, we clicked "Publish to GitHub" in Source Control. Is it possible to get "Publish to GitLab" button there as well. I assume we need to install extension like GitLab Extension and some further set up?
Could you talk a bit about SSH keys, what they are and why/how to use them?
ssh-keygen
. The private part stays on your computer and should never be moved or published anywhere, while the public one can be given to any service/host that needs to identify you. This includes GitHub, GitLab servers, HPC systems and so on.Also, could you advise WSL user to be aware where they save their local repositories? I learned the hard way that you need to be mindful about saving inside or outside WSL folders 🥲
May I add here, few questions evolve around ssh-keygen. I think, the preferred method are now tokens, which you generate on the github page, and they can expire.
Can you give recommendations (advantages/disadvantages) for using python files vs. Jupyter Notebooks regarding vscode and github?
At the moment I see no disadvantage of using codium over vs code. Is there any?
https://coderefinery.github.io/git-intro/level/
Don't know how to name your commit messages? https://www.conventionalcommits.org/en/v1.0.0/
What about git add/commit -p?
But you also said you sometimes work with collaborators who don't use GitHub and you have to do version control yourself. That could include working with Word docs, PDF's coming from the collaborator, yes?
can something be permanently removed from git history/github?
Today was (vote for all that apply):
One good thing about today:
It was good that we did similar tasks as the 1st day but locally so that we got deeper understanding.
I liked getting some insights on more "advanced" git use cases like git bisect +3
Better stepwise guidance for the solution to git bisect, had to work backwards a little bit even with the solution. Step-by-step to revert the code directly to a branch with the last working commit might be good rather than an open-ended exploration.
Great that I could follow the workshop even though I had another meeting today. Thanks for the flexible setup.
One thing to improve for next time:
Any other feedback?
General questions continued:
how can we verify if we are part of the team for collaborative exercise? Is this confirmed on registration or do we have an extra step?
You talked today about things to do and not to do. This is very helpful.
However, when I started to use git I e.g. used different folders for different branches and also modified files remotely on github and locally at the same time - without committing:(. Now, I see this is not the way you would use git. Still I am afraid that I forget to pull the right branch in the beginning of my work, or put similar files with different versions in different branches and branch merges are hard in the end.
To sum up, maybe you could specify a typical working routine like e.g. if possible to avoid confusion:
And also, would you recommend to change files only locally or only remotely on github to avoid confusions?
I would be interested in learning more about collaborating on code in a merge_request/new branch. Or if there are better options to collaborate.
If you enjoying using Overleaf and git, you might find this useful. In today's CodeRefinery workshop, I accidentally found that Overleaf can work perfectly with git. You can clone the overleaf project to your local computer, and then make modification, and commit, push back to Overleaf. Then the content on the Overleaf website would update just like how Github does. You can do whatever you like in your local repository, like creating branches, merging, etc.. Overleaf only stores your master brach. In this way one can do version control of your paper perfectly without losing all the advantages of Overleaf. Also you can still work while overleaf is down.