Overview
GitHub is a web-based hosting service for version control using git. It is mostly used for computer code. It offers all of the distributed version control and source code management functionality of Git as well as adding its own features.
Installation
To install git on your machine follow the instructions at https://git-scm.com/downloads. Once it's installed, run the command git in the terminal, and you should receive instructions on how to use git.
Set global username and email
Run the following commands on the terminal to save your information for future commits (replace with your real info, not John Doe's)
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com
Getting started with a new project
First move into htdocs with the terminal:
cd /Applications/XAMPP/xamppfiles/htdocs
Then create a new folder which will hold your project files and cd into it. to initialize a git repo in that folder do
git init .
In order to link it with the cloud repo, you have to make at least one change. Create a README.MD file in the directory, and then commit it:
git add .
git commit -m "init commit"
Log into your github account on your browser, and create a new repo, then run the following commands:
git remote add origin repo_url.git
git push -u origin master
To add a collaborator to the github repo, go to your repo, then settings, click on collaborators on the left hand side, and input their username. The user must then go into their account and accept.
Important git commands
git init .
git clone repo_url.git
git status
git add [file]
git add -A
git commit -m "commit message"
git push -u origin [branch name]
git push
git pull
git remote add origin repo_url.git
git rm -r [file]
Gitignore file
Create a .gitignore file in the root of the local repository. Git will look at the contents of this file and decide what items to ignore, such as large files not suitable for pushing. For example, a .gitignore file that excludes the large vendor folder from being pushed:
vendor/*
Make sure to never push vendor/, as it will cause headaches and reduce efficiency.
Github notes
These commands will be mostly used while working in a group project, if you encounter a problem or would like to learn more, go to https://try.github.io/. Unlimited private remote repositories are available through a fee, or by registering as a student, which is recommended. Merge conflicts can be a pain to deal with, and therefore should be resolved with atom/sublime or be avoided completely. Make sure to always pull before you push, and therefore obligating you to commit any changes.