How To Use GitHub

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4
At a glance
Powered by AI
The key takeaways from the document are how to set up a GitHub account, create and manage repositories, collaborate with others, and best practices for project structure and file management when using Git and GitHub.

The main steps to set up a GitHub account and repository are to create an account on GitHub, initialize a local repository, commit changes to it, and push the repository to GitHub. It also discusses how to fork and clone existing repositories.

The document provides guidelines for project structure such as including a README, using directories like /bin, /data, /lib, and /out. It also mentions ignoring files from version control using a .gitignore file.

How To Use GitHub

Setting Up A GitHub Account


Go to this link and follow the instructions

How To Set Up Your Project Folders


Just clone skel This is still connected to the original GitHub repository so you want to make a copy that does not have git in it so you can work on the project and add it to GitHub separately To do this cd into skel and type git archive --format zip --output /full/path/to/dataproject.zip master Now you can unzip it and build you data driven journalism project If you want to build from scratch: README.md at the top level of your project folder run.sh: your le to run on the command line, that le must transform /data and produce data in /out /bin: python scripts, bash scripts e.g. scrapers and parsers /data: the original data les e.g. raw html, csv downloads, list of urls /lib: third party libraries and software /out: somewhere to leave the output and intermediate data acted upon later, actions will leave output documents there Note: /out may be sub directoried Vagrantfile: builds your virtual environment with all the software you need to run the project /vagrant: if one is required Readme in the absence of docs, this should contain description of the project, detailing of the sources and outputs, together with any philosophical and impertinent facts It must detail explicitly what is to be done Copy the README.vagrant.md into the top of your projects folder 1

How To Make A Repository


cd into the place where you code is Type: git init It is now a git repository Type: git gui # a graphical commit tool pops up In the left hand box click on the doc icons of the les in the Unstaged Changes column This then goes into the Staged Changes (Will Commit) Type your commit message into the Initial Commit Message box Hit Commit button Close gui window Go to your online GitHub account and hit New Repository Give the project a name and a brief description then hit create repository Before you proceed make sure you have congured your git username and email git cong global user.email [email protected] git cong global user.name Your Name Here Type in the following commands: git remote add origin [email protected]:DataMinerUK/skel.git git push -u origin master # Note the http stu GitHub tells you to put in is wrong

How To Make A Repository Private/Public


Private repositories are a premium feature of the github site. A user can typically only have a limited number of private repositories. Any number of public repositories is ne. This encourages social coding. :) Repositories can be marked private when they are created. Or the privacy can be changed from the repository admin page on github later.

How To Clone A Repository


Go to the repository on GitHub Hit SSH at the top Copy the address In your terminal navigate to the folder you want the repository to appear Type git clone "address you copied" Enter username and password

How To Fork A Repository


Go to the repository on GitHub and hit Fork on the top right Choose the account you want the repository in If you then want this on you local machine you can clone it as above

Adding To A Repository
Once you have made changes you can go to the git gui and follow the same instructions on How To Make A Repository above Or just type git add . Then git commit -m "your commit message" Then git pull to make sure you have the latest version to push to Then git push

Ignoring Parts Of A Repository


There is a special le called .gitignore. This is a list of les which git will ignore when you are doing adds and commits. So for le ignoreme that you want to ignore, open .gitignore and add ignoreme on its own line in the .gitignore and git wont bother you about it anymore. .gitignore is usually put at the toplevel of the project. Temporary data, compiled les, IDE conguration les, etc are all the kinds of things that you might be included in .gitignore.

File patterns are also acceptable, e.g. *.tmp for any le that ends in .tmp. To make a .gitignore just type in the command line touch .gitignore Open this le in a text editor by selecting open and in Finder tick Show hidden les In the .gitignore le write the name of the le or folder you want ignore e.g. data to ignore the data folder, tmp to ignore tmp folder and les called tmp in any folder You can use * here also. It will replace any sequence of characters except / The .gitignore le is checked in as usual

WARNING
DO NOT COMMIT VERY LARGE FILES INTO GIT. These will massively increase the size of the repository and make all git actions slow. So watch out for massive data les in your project!

You might also like