Top Banner
VERSION CONTROL SYSTEM git ECE 650 - REZA BABAEE
20

ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

Sep 24, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

VERSION CONTROL SYSTEM git

ECE 650 - REZA BABAEE

Page 2: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

LEARNING OBJECTIVES

▸ Explain what a version control system (VCS) is

▸ Identify git and its commands as a VCS

▸ Apply git commands to manage the assignments

Page 3: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

WHAT IS VERSION (REVISION) CONTROL SYSTEM

▸ A system for managing changes to documents, programs, web pages,…

▸ Maintains a revision history of changes to the document

▸ Maintains multiple versions of a document

▸ Enables multiple users to collaborate on a common collection of documents

▸ There are many revision control systems available

▸ rcs, cvs, subversion, mercurial

▸ git

Page 4: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git HISTORY

▸ Developed by the Linux development community

▸ Linus Torvalds, 2005

▸ Initial goals

▸ Speed

▸ Simple design

▸ Strong support for non-linear development (thousands of parallel branches)

▸ Fully distributed

▸ Able to handle large projects like the Linux kernel efficiently (speed and data size)

Page 5: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git RESOURCES

▸ From the command line

▸ git help to get a list of commands

▸ git help <cmd>

▸ where <cmd> is a git command (e.g., add, commit, fetch, merge)

▸ On-line book

▸ https://git-scm.com/book/en/v2

▸ Tutorial

▸ https://git-scm.com/docs/gittutorial

▸ Interactive Tutorial on GitHub

▸ https://try.github.io/

Page 6: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git commit

▸ A snapshot of all the files in the directory

▸ Lightweight copy-and-paste

▸ Only stores the changes from one version to another (called delta)

▸ git keeps a history of commits

▸ git commit <file> | -a (all files) -m “<message>”

Page 7: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

SNAPSHOTS, NOT DIFFERENCESdifferences

snapshots

Page 8: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git add

▸ Making git keep track of a file/directory (so-called staging the file/directory)

▸ git add <filename> (not required if using -am in git commit)

Page 9: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git branch

▸ Pointers to specific commits

▸ A branch essentially says "I want to include the work of this commit and all parent commits.”

▸ git branch <name of branch>

▸ git checkout -b <name of branch>

Page 10: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git merge

▸ Combining the work from two different branches

▸ The workflow so far:

▸ Branch off

▸ working on a feature, fixing bugs, etc.

▸ Combine back in

▸ Merging creates a special commit with two unique parents

▸ git merge <name of the branch to be merged>

Page 11: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git merge - Example

▸ git checkout master

▸ git merge dumbidea

▸ git merge iss91v2

Page 12: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

DISTRIBUTED VERSION CONTROL SYSTEM

▸ So far working on a local directory

▸ Making VCS distributed

▸ backup!

▸ Social coding!

▸ Remote repositories: copies of your files on other computers

▸ Free git servers: gitHub, gitLab, bitbucket, phabricator, …

Page 13: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git clone

▸ Creates a local copy of a remote repository

▸ git clone [—recursive] <username>@<remote address> <name-of-local-directory>

▸ Requires

▸ ssh: uses a ssh-key for authentication or

▸ https: asks for username/password on the a CLI

Page 14: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git status

▸ Gives the status of your git repository

▸ Untracked files

▸ Changes that are not committed

▸ Your current local branch

▸ Changes between the local and the remote branch

▸ The remote and the remote branch <remote-name>/<remote-branch>

Page 15: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git pull

▸ Downloads the remote repository (so-called fetching), and merges the current local branch into the remote branch

▸ git pull (there is a remote added to the git once you cloned, so git knows where to fetch from, you can change it)

Page 16: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

git push

▸ Uploads the local branch into the remote branch

▸ All people having access to the remote branch can see your changes

▸ git push

Page 17: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

COMMON git WORKFLOW

▸ init or clone

▸ Create an empty repo or make a local copy of a remote repo

▸ Edit some files, create and modify content

▸ add (or stage)

▸ mark changes to be combined into a commit

▸ a commit is a unit of change, a new version

▸ each commit has a globally unique name (i.e., 029389678201859fd6838c8b6c059edd0f17efcf)

▸ Commit

▸ create a commit based on identified changes

▸ push

▸ propagate changes to remote repo

▸ fetch or pull

▸ download changes from remote repo

Page 18: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

TIPS - COMMITS

▸ Commit your changes after each unit of work

▸ Use appropriate messages for your commits

▸ Separate subject from body with a blank line

▸ Limit the subject line to 50 characters

▸ Capitalize the subject line

▸ Do not end the subject line with a period

▸ Use the imperative mood in the subject line

▸ Wrap the body at 72 characters

▸ Use the body to explain what and why vs. how

Page 19: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

TIPS - BRANCHING

▸ Branch early branch often next version to replace (merge into) master

▸ master – stable version

▸ only stable, well-tested commit

▸ develop – development version

▸ next version to replace (merge into) master

▸ topic – experimental bleeding edge

▸ test stuff out before merging into develop

Page 20: ECE 650 - REZA BABAEE VERSION CONTROL SYSTEMrbabaeec/ece650/w20/assets/pdf/...COMMON git WORKFLOW init or clone Create an empty repo or make a local copy of a remote repo Edit some

SUMMARY

▸ What is a version control system?

▸ What features git provides for VCS?

▸ git commands

▸ The tips on git commits and branching