workflow tutorial: getting started with git basic commands ...cs349/s18/lectures/git tutoria… ·...
TRANSCRIPT
![Page 1: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/1.jpg)
Tutorial: Getting Started with GitIntroduction to version controlBenefits of using GitBasic commandsWorkflow
![Page 3: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/3.jpg)
Tutorial Objectives
▪ Fundamentals of how git works▪ Everything you need to complete A0▪ Some best practices▪ Useful Commands
3
![Page 4: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/4.jpg)
Version Control Systems
4
▪ Goal of a Version Control System- Software that manages changes that you make to your files
(source code).- Track versions of each file (more accurately, versions of sets of
changes to your files).- Handles concurrent changes from multiple sources (e.g. different
developers working on the same code base).- Typically central repository stores every version of every file.
![Page 5: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/5.jpg)
Distributed Version Control
5
▪ Distributed version control systems (DVCS)- No central server required! - Every user has a copy of every file.
▪ We use Git, a very popular DVCS. - Developed in 2005, to manage development for the Linux kernel
(Bitkeeper -> Git)- Very specific design goalsLarge-scale development
Distributed
▪ Git doesn’t require a server, but it’s common to use one for coordinatione.g. Github
![Page 6: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/6.jpg)
Concepts
6
▪ Working directory- your local copy of the files that you’re working with.
▪ Staging area- a “place” where you tell Git to hold a set of changes, temporarily.
▪ Repository- a place where Git stores copies of your files and their history.Local repository: on your working machine
Remote repository: a server (e.g. GitHub)
![Page 7: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/7.jpg)
7
![Page 8: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/8.jpg)
Commands
8
▪ You perform these operations using a Git client (command-line or GUI, the work the same).
▪ Commands typically move files between working directory, staging area and local or remote repository.
![Page 9: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/9.jpg)
Installing Git
9
▪ Before anything else, you need to install and configure Git.
▪ Install a Git client (command-line or GUI)- https://git-scm.com/downloads
▪ Setup your email address for Git: git config --global user.email "[email protected]"
![Page 10: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/10.jpg)
Working on A0
10
Get a copy of the repository from the server
git clone https://[email protected]/cs349-fall2017/username.git
– Use ‘git clone’ to get a copy of starting code from remote repository to your working directory:
Work on the assignment
Save and commit your changes to git
Push changes to the server
![Page 11: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/11.jpg)
Working on A0
11
Get a copy of the repository from the server
Work on the assignment
Save and commit your changes to gitgit add results.txt
– to add files to your staging areagit commit
– to save the changes to the local repository.
Push changes to the server
![Page 12: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/12.jpg)
Working on A0
12
Get a copy of the repository from the server
Work on the assignment
Save and commit your changes to git
Push changes to the servergit push
– to push to the remote repository.
![Page 13: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/13.jpg)
“Good Ideas”
13
▪ Consider cloning via SSH or HTTPS.- For SSH, generate public/private keys.https://git.uwaterloo.ca/help/ssh/README
- If you use HTTPS, you might want to cache credentialshttps://git-scm.com/docs/git-credential-store
▪ Learn how to use tags or branches- See documentation
![Page 14: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/14.jpg)
Gitignore
14
▪ Files to gitignore- Compiled and generated files- Sensitive information
▪ Creating a gitignore file doesn’t remove files that were previously committed, so to to remove those files from git without deleting them from the filesystem you can use- git rm -r --cached . - git add .
▪ Useful, common gitignores- https://github.com/github/gitignore
![Page 15: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/15.jpg)
Useful Commands
15
▪ git status- Displays the current files that have changed and files in the
staging area.▪ git diff- Shows file by file the changes you’ve made
▪ git add -A- Adds all files to your staging area
▪ git commit -am”Your message here”- -a automatically adds all all modified files to your staging
area- -m allows you to add a message on the command line
rather than opening an editor
![Page 16: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/16.jpg)
Tips
16
▪ Commit often▪ Write detailed commit messages▪ Group your commits into atomic functionality
![Page 17: Workflow Tutorial: Getting Started with Git Basic commands ...cs349/s18/lectures/Git Tutoria… · Useful Commands 15 git status-Displays the current files that have changed and files](https://reader033.vdocuments.net/reader033/viewer/2022052423/5f0b63447e708231d430457c/html5/thumbnails/17.jpg)
Resources
17
▪ Git Home- documentation, binaries- https://git-scm.com
▪ Git Reference- cheat-sheet of commands- http://gitref.org
▪ Book: Pro Git- Scott Chacon and Ben Straub- extensive manual
▪ Ry’s Git Tutorial- http://rypress.com/tutorials/git/index▪ Git branching strategy- http://nvie.com/posts/a-successful-git-branching-model/