Getting started in Git - rlsweeney/Sweeney_RA_Manual GitHub Wiki
Setup
-
Create an account on GitHub
-
Install git on your computer.
Pick how you want to interact with Git/ GitHub
- People typically interact with Git and GitHub from the command line (or Git Bash). If you are comfortable with the command line, this is the easiest.
- If you prefer to work with a gui, you can install GitHub desktop. Detailed instructions on using GitHub desktop here
- I used to use SmartGit (free for academics) which I liked.
- I currently mainly use VS Code (for editing and working in repos generally). It has a built in Git tab which allows you to easily see file changes, commit, etc.
- Note: Whichever you choose, be sure to install git standalone first. This will make switching easier later.
Install Git Large File Storage
Git does not do well with large files/ large binary files. [GitHub will not even track files > 100 MB]
- Install Git LFS
- can check that it's installed by
git lfs install
- can check that it's installed by
- Pick the files you want to use for lfs.
- For example:
git lfs track "*.png"
- For example:
- Make sure you track
.gitattributes
git add .gitattributes
Working in Git
- Clone the repository
To work with a GitHub repo, you'll "clone" a local copy onto your machine.
Important: Do not save github repos to Dropbox.
I use the structureC:\Gitdir\Projects\[repo name]
If this is the first time you're cloning the repository to a given machine, you may need to create untracked files telling your code where the local dropbox folder for the project is.
- Make sure you're on the right branch
We will almost never be working on the
master
branch locally. More on branches here.
Make sure you've cloned the version you want to work in and checked it out locally.
- Commit any local changes that you want to keep.
- Be sure to give the commit a sensible (if short) message saying what you did.
- Push the changes back to GitHub.
- If you want to pick up this work on another machine or share with the team, make sure you push your changes back to the remote branch you're working.
Setting up dropbox link
- We need to tell code in GH where our respective dropbox folders are
- See the README.md page for repo - specific instructions.
As an example:
- create a "setup.R" file in your local copy of the repository telling R where this folder lives on your computer.
- save this in the main
code
folder, change the path, and resave it as setup.R - it is important that you do not sync this folder with GH!
- can do this by adding "setup.R" to the .gitignore file