Introduction to Git and Github
May 22, 2015
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It's goo habit use version control what multiple people or just one working on a project. A primitive way of version control which a lot people use is to copy files into another directory. This approach is simple, but there are a lot of ways to make mistake.
Git is system for version control of files that was created by Linus Trovalds. It allows you to easily store, update and manage versions of files. Git provides the ability to update and edit the project files to reflect changes made by others. Every time you commit or save the changes of your project, Git makes duplicates of the original file. Developers use git and other version control system because they allow to see the changes made by other developers, easily roll back changes and convenient operation via the command line. In turn, Github is the largest web hosting service for IT projects based on the version control system Git. So if Git is a command line tool, GitHub provides a Web-based graphical interface
Create a new repository
- In the upper-right corner of any page, click , and then click New repository.
- In the Owner drop-down, select the account you wish to create the repository on.
- Type a name for your repository, and an optional description.
- You can choose to to make the repository either public or private. Public repositories are visible to the public, while private repositories are only accessible to you, and people you share them with.
- When you're finished, click Create repository.
Forking repo
- Go to the repository which you would like to fork
- In the top-right corner of the page, click Fork.
Cloning
- Open the terminal and check where you are (pwd).
- Go to the directory where you will store the repo.
- In the command line type git clone https://github.com/[USERNAME]/[Name]
Git cheatsheet
- git status - changed files in your working directory
- git clone [file] - clonning an exesting repository
- git init [name] - creates new local repository
- git add . - add all current changes to the next commit
- git add -p [file] - add some changes in [file] to the next commit
- git commit -m [message] - commits file and adds short descriptive message
- git diff - changes to tracked files
- git branch -av - list all existing branches
- git checkout [branch] - switch branch
- git push origin [branch] - publish local changes