<- fs::path_home(".gitconfig")
fil fil
/home/haf/einarhj/.gitconfig
During a web-session we will follow the slides by Alice Barlett: Git for humans. If you missed that or care to revisit the message therein you can also listen to Alice present this hereself (and she is actually much more fun presenter):
You need to have git installed on your computer. If you are on Mac or Linux you get it as a part of the setup, but the default setup of Windows does not include it. Instructions on checking if you have git already installed or if not, how to install it on Windows check Chapter 6 in Happy Git and GitHub for the useR
When installing git a special configuration file is generated and stored on your computer. We can locate it via:
and see its contents by:
Another way to view the git-configuration is via:
── Git global (user)
• Name: 'einarhjorleifsson'
• Email: 'einar.hjorleifsson@gmail.com'
• Global (user-level) gitignore file: <unset>
• Vaccinated: FALSE
ℹ See `?git_vaccinate` to learn more
ℹ Defaulting to 'https' Git protocol
• Default Git protocol: 'https'
• Default initial branch name: <unset>
If the name or email is not yet specified in the .gitconfig file the safest way to do so is via edit_git_config
:
If you are going to use github, the email must be the email associated with that account. For simplicity sake it is also suggested that the user.name you use here is the same as the username on github.
Once you have completed installing git you can easily create a new RStudio project that includes git via:
File -> New Project ... -> New Directory
in that dialog box select "Create a git repository"
If you already have an RStudio project and want to make it a git-repository run the following command within that project:
You will be asked a bunch of questions, say no to the first set and then yes to the second set (request to restart RStudio)
Let’s collectively generate a new RStudio git project/repository
Open an R script and type in some code and then save
Commit the work
Open the R script again and work some more on it and then save
Commit the work, checking how we see changes etc.
Lets also try to create a branch, work on it, switch back and forth between the main and the branch etc.
As a part of the exercise let’s also cover how to open a passed snapshot of the project development.
Working with git solely on your own computer only saves a snapshoot of the development of your project work. But this does not create a backup of your work. You could of course take a backup copy of your whole project directory like on the institutes central computer or on some external harddisk (you of course do take regular backup of your work, don’t you????).
One way to make a backup of your work is to use github. It also opens up the possibility of communication of your work with others. You can consider github as the social network of coders.
As of getting around git is not enough, working with github.com has of lately be a little bit more cumbersome because of added security. In older days it was sufficient to know just your password to communicate with github.com but now we have 2-way authentication and github credentials. These will have to be dealt with first, before we start to see the real benefit of us using github.
… pending
… pending
Plenty of material on the web but I like e.g. this one and the links therein as a starter.
Some other useful things: