introduction git

29
GIT Introduction Version Control System Dian Sigit Prastowo & Agastyo Satriaji Idam

Upload: dian-sigit-prastowo

Post on 14-Apr-2017

66 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Introduction git

GIT IntroductionVersion Control System

Dian Sigit Prastowo & Agastyo Satriaji Idam

Page 2: Introduction git

Problem

Page 3: Introduction git

Version Control System“A version control system (sometimes called revision control) is a tool that lets you track the history and attribution of your project files over time (stored in a repository), and which helps the developers in the team to work together. Modern version control systems help them work simultaneously, in a non-blocking way, by giving each developer his or her own sandbox, preventing their work in progress from conflicting, and all the while providing a mechanism to merge changes and synchronize work.”

“Mastering Git.”

Page 4: Introduction git

Version Control System

Page 5: Introduction git

What is GIT?Git is Distributed Version Control System

“Distributed means that there is no main server and all of the full history of the project is available once you cloned the project”

Page 6: Introduction git

A Brief History• In 2002, the Linux kernel project bega using a

DVCS calld BitKeeper.• In 2005, the commercial company that

developed BitKeeper broke down, and the tool’s free-of-charge status was revoked.

• This prompted the Linux development community (and in particular Linux Trovalds, the creator of Linux) to develop their own tool - GIT

Page 7: Introduction git

First of all, definitions • Working tree

A directory in your filesystem that is associated with a repository, containing files & sub-directories• Repository

A collection of commits & branches, saved in the .git directory• Commit

A Snapshot of your working tree at a certain point in time, identified by a revision number.• HEAD

The name for the commit thats currently checked out in.

Page 8: Introduction git

GIT• You can imagine git as something that

sits on top of your file system and manipulates files.

• This “something” is a tree structure where each commit creates a new node in that tree.

• Nearly all git commands actually serve to navigate on this tree and to manipulate it accordingly.

Page 9: Introduction git

GIT CommandsVersion Control System

Dian Sigit Prastowo & Agastyo Satriaji Idam

Page 10: Introduction git

Commands• git config

• git init

• git add

• git rm

• git commit

• git log

• git diff

• git status

• git reset

• git branch

• git checkout

• git merge

• git remote

• git clone

• git push

• git pull

Page 11: Introduction git

Install Git on Windows

• Download the latest Git for Windows installer git

• Started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation.

• Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt).

• Run the following commands to configure your Git username and email using the following commands:

$ git config --global user.name “Dian Sigit”$ git config --global user.email "[email protected]

Page 12: Introduction git

Configuration

Page 13: Introduction git

Local Repositorygit init

git-init - Create an empty Git repository or reinitialize an existing one

Page 14: Introduction git

Local Repositorygit add

git-add - Add file contents to the index

Page 15: Introduction git

Local Repositorygit rm

git-rm - Remove files from the working tree and from the index

Page 16: Introduction git

Local Repositorygit commit

git-commit - Record changes to the repository

Page 17: Introduction git

Local Repositorygit commit

git-commit - Record changes to the repository

Page 18: Introduction git

Local Repositorygit log

git-log - Show commit logs

Page 19: Introduction git

Local Repositorygit diff

git-diff - Show changes between commits, commit and working tree, etc

Page 20: Introduction git

Local Repositorygit status

git-status - Show the working tree status

Page 21: Introduction git

Local Repositorygit reset

git-reset - Reset current HEAD to the specified state

Page 22: Introduction git

Local Repositorygit branch

git-branch - List, create, or delete branches

Page 23: Introduction git

Local Repositorygit checkout

git-checkout - Switch branches or restore working tree files

Page 24: Introduction git

Local Repositorygit merge

git-merge - Join two or more development histories together

Page 25: Introduction git

Installing SSH keys on Windows

• To access your Git repositories you will need to create and install SSH keys

• Generating a key pair, ssh-keygen -t rsa• Copy the public key, and paste on gitlab SSH Key

Settings, cat ~/.ssh/id_rsa.pub | clip• Checking your connection, ssh [email protected]

Page 26: Introduction git

Collaboration Repositorygit remote

git-remote - Manage set of tracked repositories

Page 27: Introduction git

Collaboration Repositorygit clone

git-clone - Clone a repository into a new directory

Page 28: Introduction git

Collaboration Repositorygit push

git-push - Update remote refs along with associated objects

Page 29: Introduction git

Collaboration Repositorygit pull

git-pull - Fetch from and integrate with another repository or a local branch