Materials: Continuing with Git intro
What do we need to follow this lesson?
Does the stream on Twitch work for anyone?
where i can see this document which shown now on twitch
Do we learn staging in the coming days? I still do not figure out exactly when it is best used. Is it better than many small commits?
It is really helpful to go through the notes after the sessions, will these notes be available indefinitely?
In the workflow I have with my colleagues I develop code in MATLAB that is then automatically translated to CPP code using MATLAB coder and tested. The code needs some manual changes before it can go through MATLAB Coder. Usually my colleagues create two copies of the files in the repository with and without these changes. The rational for using copies (rather than branches) is that they need to test that behaviour is still same, which is easier having copies of files than branches. Usually to continue working on further developments I should take the changed files. It fells somewhat wrong to have under source several versions of same file. Could you comment on how we could do this better?!
In VS Code, do you have a list of recommended extensions? Any that is a must?
Let's say I create a release/tag of a version of my code, and my colleagues take that version to another repository, where they have also other modules. What are the tools for merging the code that is common between the repositories later?
Can I easily have and edit two branches at same time in different folders in my computer?
How to add a new release when an existing one is already there, there is no button to create new release!
How to add v1.0? The button did not show up in my GitHub?
Just an observation: Creating a DOI does not guarantee that an asset will "never disappear" - digital archiving is a huge challenge: https://www.nature.com/articles/d41586-024-00616-5 - Good point. It is not a guarantee but better than having only a repo (which is better than having no repo). But thank you for the clarification.
Isn't it difficult to work on e.g. Python scripts on GitHub? Since I have to test them while modifying them. Then GitHub would just be a place to upload my files, right? With more functionalities of course. Is there anything I'm missing? +1
When creating new branches locally you can either use the Git switch command or the Git checkout command. What is the difference?
git switch
is explicitly for branch switching.Should we clone the origin repository or our forked version?
Is there a way to turn on autofill suggestions in Git Bash (Windows)?
In source control I see "initialize repository" and "publish on GitHub". I do not see clone repository.
what is the difference between HTTPS and SSH?
In team/on your own: until XX:00, then we reconvene briefly on Stream Try to do most of this. Follow solution if you need, it's designed to be followed I am:
done: ooooooooo
not trying: o
had problems: oo
everything was good: ooo
tested RStudio path : o
There is only 'Publish Branch' button, when I click Git button on VS Code
What is the difference between committing and staging?
I do not see the branches in VS Code explorer after cloning, I do not even know the branch I am in at the moment.
I created a new branch in VS Code and I am trying to merge it to main but in the version contol view "... -> Branch" there is no option Merge branch available for me. I am within the main branch.
The commit (new file) I created locally in a new branch is also visible when I switch to the main branch. It was not the case while working on GitHub. Where is this difference from?
git log --oneline main
git log --oneline THEOTHERBRANCH
I got the following error (screenshot removed)
How to go inside the repository from Git?
Is there a reason that I do not see any remote branches when I do git branch --all
? I only see my own remote branches which are:
remotes/origin/HEAD -> origin/main
remotes/origin/main
Should I only see the remote branches of the forked repo, or also the one in the upstream?
I want to try to use VS Code and Git. When I want to commit one of my changes, I get an error message asking me to make sure I configured my set-up. I already configured my Git with Git config user.name "my user name" and Git config user.mail "my email adress". Besides, I am connected with my GitHub account on VS Code. Do you have any idea what I should do?
git config
without --global
so that it set user.name and user.email only for a certain repo?If I am working alone, can my remote repository then be considered a backup? But if we collaborate then it is a must to have a remote, to share, but can also be considered a backup?
DO we use the powershell terminal in VS Code or the Git bash?
$
? If so, likely git-bash.When we created a file Git didnt track the file, and therefore VS Code didnt show anything in the status. It only worked after the file had some content. Why?
I made suggestion on explanation on a webpage about VS Code part. Otherwise its nicely explained.
How do I see the commits history in VS Code? And is there any way to visualise also the network?
Is the last commit of a branch also called HEAD, or it only applies to main?
As I understand we should not use Git for files that can be regenerated, e.g. plots? Is there a way to setup so that some files/folders are never under Git under a project?
What is origin/HEAD and origin/main?
We didn't hear the jingle :(
Doesn't it give a problem in the path when the instructor names his branch username/whatever slash?
How to step outside? How to move up in folder hierarchy? In Git bash
cd ..
to move one level up; you can use pwd
to check "where you are"I got an error (screenshot removed)
pwd
show in git-bash? It would show where you currently are (I hope)/
.
What exactly is the fixme?
In team/on your own: until XX:50 Try to do most of this, steps 1-5. Follow solution if you need, it's designed to be followed. Bisect part is optional. I am:
done: ooooooo
not trying: o
had problems: ooooo
everything was good: oooo
I can't find the string...
main
but that you first "downgrade" your clone to the particular older version. The text might have disappeared in the past. But maybe you are on GitHub where it might be more difficult to search through a past version?
Could you make an example how to write command line for this: "Use /sometext <ENTER>
to find “sometext” and you can cycle through the results with n (next) and N (last)."
what is the command for these; "Find out when this line was last modified or added. Find the actual commit which modified that line".
Is it possible to do the exercise merely using the VS Code than command-line?
Do we need to find the commit that simply modify that line (they just added a space) or the one that created it? I assume the former, but the code hadn't change really
My terminal doesn't go to less?
your command | less
less
git config --unset core.pager
would un-do it.Could you clarify where the branches are saved (like in which folder) in my local computer when I create branches locally? I cannot find them
.git/refs/heads/
in particular).Still do not find the actual commit that modified the line, with "git annotate networkx/algorithms/threshold.py".
Could you please briefly explain how to do the last question of the exercice on GitHub?
How am I supposed to create a branch pointing to the past when I have not cloned, according to the instructions in GitHub? I do have it in VS Code however, but not sure how to point to that commit. I think it is a bit confusing when we can use both GitHub, terminal and VS Code.
Hi! For some reason when i tried to "git switch --create HASH-1", it returned an error "fatal: invalid reference". Any ideas as to why?
I think this exercise was too fast and not properly explained
Heard the jingle!
Still do not find the actual commit that modeified the line, with “git annotate networkx/algorithms/threshold.py”
git annotate exits the file after printing its content, so I cannot type the "/Logic error"
If I create a local branch from a remote branch, where the new information is saved? Since the branch is not from the local repository
Does remote branch always start with origin
Could you explain more with example what command should be written for this? How to write less and n and N? (screenshot removed)
git log
starts another program that can scroll up and down. This program is called less
. It's controlled by the keyboard (once it starts). Keyboard shortcuts (inside the program): "n", "N", "/".less
. In which case, we can't help much - I would suggest going on and asking someone locally.Exercise list for those who need a credit has been updated: https://coderefinery.github.io/2024-03-12-workshop/certificates/ Remember that credit/certificate is available only for those affiliated with a higher education institution.
/tree/HASH
(replace HASH) behind any github repo and you can see how it looked back thenIn team/on your own: until XX:35 -> Try to do most of this. Experiment a bit. Follow solution if you need, it's designed to be followed. Add questions and thoughts below (also from earlier sections), these will be discussed on stream after.
I am:
done: ooooooo
not trying: oo
had problems: oo
everything was good: oooo
After publishing it ask on VS Code if I want VS Code to periodically run "git fetch", what do I do?
git fetch
fetches commits that you don't have locally and updates remote branches but does not modify any local branches. I think this can be useful so that you always have also remote commits available on your computer if you need them, without having to actively fetch them. In short: it should not interfere with local branches.Hi! I was trying to push an existing repository by command line, but I got the error "src refspec main does not match any". Any ideas on what went wrong?
git push -u origin main
(main
is branch to push, origin
is remote name, -u
says "remember this for later")git status
or git branch
Why using VS Code instead of GitHub? I did it so much faster on GitHub, I think.
Is it really necessary to create an empty repository on GitHub? In VS Code I can just “publish to GitHub private (or public) repository with username/myproject.
Ok, so I can publish to GitHub without first creating a repository, but that does not seem to work with GitLab?
In making changes to a file in a local repository, after committing is asked "would you like to stage all your change and commit them directly?". What should be done here?
If we're doing this on GitHub, we don't really do step 3, right? Just trying to understand this fully.
Created a readme file on the Git remote repository, how to make it reflect in the local?
When I want to push to origin, I receive an authentication error: remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed how can I avoid this?
How to delete a repository, then, on GitHub and also by using VS Code (if possible)?
I got this error: "error: failed to push some refs to github.com:[my user/repo]"".
How to disconnect with git? Once I establish a folder connecting with git, the VS Code Git also notifies me 'commit'.
Is there anyway to change the Git repository from private to public? Because I am unable to view network with the private on GitHub.
We call these projects but on GitHub they are called repositories. On GitHub they also have "Projects"?
What is the file extension for the file LICENSE? Is there a set way for creating a license file?
In the timeline tab of VS Code, why does my timeline show a lot of "File Saved"?
When should we initialize the .gitignore file? If there are files from a format that I want to exclude but that are in the history of git, creating a .gitignore file does not allow us to get rid of these. What should I do then to remove these. Ex: I clone a repo with NN weights. These files are very heavy. So I create a .gitignore file. But these files are still on the history.
Can I have different .gitignore files for two local repositories of the same repo?
.git/info/exclude
(the .git
dir of each repo) is a non-tracked ignore file - per local computer.I can understand using Git for code, but what about more complex files, e.g Word documents?
How to turn a project into a GitLab repository instead of a GitHub repository?
Is Git the best way to handle projects with a lot of non-code assets, like videogames with binary 3D files? How do you handle the changes to those files?
When would you clone vs fork a repository? If I want to play with someone's code, maybe make some own changes but don't want necessarily to share it back, perhaps cloning is OK?
Could you explain what .gitignore file does?
*.out
if you want to exclude output files with that suffix.
Any preparations we should do for tomorrow's sessions today already? Creating local files, folders, repos?
Are there things that you often do only on GitHub/GitLab vs. command line and vice versa.
I noticed that RStudio as an option for commit signing in the commit dialog. Is there benefit of cryptographically signing commits in the context of (academic) research?
When I use the command: ssh -T git@github.com, I will get You've successfully authenticated, but GitHub does not provide shell access.
. I have set the ssh keys in GitHub to the best I know.
But then I recieve the same error as before when I want to push the origin.
The exact same message? Hm...
Yes, is not it related to the second part that says shell access is not provided?
Which error do you get?
Is you remote using Git protocol? git@github.com:USER/repository.git? (vs https://github.com/USER/repository.git). You can see this with git remote -v
git remote -v
gives me https://github.com/USER/repository.git which is what I added as origin via ``git remote add origin https://github.com/USER/repository.git
That's it then, change it to git@github.com... : git remote remove origin
and git remote add origin git@github.com...
. Using https protocol tries to use password authentication which as it says was removed.
From the VS Code code pathway, how to publish project to a GitLab repository instead of GitHub, given that from start the only option is GitHub.
When working locally, Git will keep track of each previous version to be accessible even years after. All this information must be stored I understand. Can this become a problem with the time? Does Git uses some compress format?
How come that I can publish directly from VS Code to GitHub, without first creating an empty repository on GitHub, compared to GitLab where I have to first create an empty repository? Or am I wrong?
Bring cat back
Is there a way to do automatic Git commit to avoid losing work? Perhaps a bad way to use git? Because I also use Time Machine which use versions and automatic backup. Perhaps something like a commit with backup in the commit text.
Is there a practice to join commits? Sometimes I go fixing really small things like typos and several times a day. Could I join my commits of the day and write a sensible description for that one big commit (like fixed several typos, wrote documentation, etc.)
Is not most code developed under certain employment proprietary? How do you build your GitHub portefolio? Mostly from project done on free time?
Today was:
Rstudio track was:
One good thing about today:
One thing to improve for next time:
Any other feedback?
News for day 2: