How to use Git and Github

What is Git?

According to the GIT software website:
https://git-scm.com/

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is easy to learn and has a tiny footprint with lightning fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.

Git is a software tool that once installed on your machine, takes in commands at the command line, allowing you to quickly and easily manage versioning of files in a project. Git allows branching, forking, and Diff analysis between versions of code. Here is a glossary of common lingo used with Git:

Project: Repository or “repo”.

Working directory: The location on your computer where your project lives.

Staging: Preparing or getting ready. Move the selected modified files into staging area before committing.

Commit: Git’s way of “saving”.

Command line: A place where we can type commands.

push: Push changes from local Git to GitHub.

pull: Get changes from Github down to local computer.

clone: Copy an existing repository from a server to our computer’s hard drive.

branch: A parallel version of a repository.

master: The primary branch.

fork: A personal copy of another user’s repository.

For a more comprehensive Git glossary, see:
https://help.github.com/articles/github-glossary/

 

Common Command Pattern

When working on a project, the most common commands that are used after saving an edit to a project file, (listed in order of pattern usage) are init, status, add, commit, and push. These commands are run one at a time, hitting enter after each:

Init:

git init

then status:

git status

then add:

git add .

then commit, with a message that states what was changed:

git commit -m “Added a header to the main page.”

Then, if you are using github, push the changes up to the github repo:

git push

 

What is Github?

According to the Github website:
https://github.com/

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

Note: When publishing to github, your code is available for anyone to see or fork against, so if you want to keep your code private or your code is commercial, then do not publish to github.

To get started with github, go to github.com and sign up. After that, you can create a new repository by clicking the + symbol. For example:

Then give your repository a name. For example:

Finally, set this new repository as an origin by running the command:

git remote add origin https://github.com/chris-relaxing/parse_jupyter.git

then:

git push -u origin master

Once a project is pushed to this repo using git push for example:

then check github to confirm that the update was pushed:

For more information about using git and github, see:
https://git-scm.com/doc
https://guides.github.com/activities/hello-world/