Download presentation
Presentation is loading. Please wait.
Published byMartina Richard Modified over 9 years ago
1
Git
2
What’s Git? A British swear A Distributed Version Control System Developed in 2005 by Linus Torvalds for use on the Linux Kernel Git Logo by Jason Long used under Creative Commons Attribution License. See http://git-scm.com/downloads/logos
3
2 b i α 1 b i 1 a i How does Git work? Maintains a repository of changes to a folder The directory can be “saved” (committed) or “opened” (checked out) at any version Working Tree Repository 0ef19fe14ce 997bf04ea5 5f7b5ac909 Folder icon in public domain. See http://openclipart.org/detail/137155/folder-icon-by-jhnri4-137155
4
But wait, there’s more! You can branch your tree, so you can work on multiple features at once You can share your changes with other developers Repository 0ef19fe14ce 997bf04ea5 5f7b5ac909 282bd722f 360acfe22 Repository Other Repository
5
How do I start with Git? Install it ◦Command line ◦GUI version Create a new repo with git init ls app bower.json css Gruntfile.js img js node_modules package.json test git init Initialized empty Git repository in ~/gitdemo/.git/ $> $>
6
How do I add files to Git? Files and folders are not tracked by default Files must be staged before committing with git add git status # On branch master # Initial commit # Untracked files: # (use "git add <file>..." to include in what will be committed) # Gruntfile.js # app/ # bower.json # img/ # package.json # test/ nothing added to commit but untracked files present (use "git add" to track) $> $> $> git add. git status # On branch master # Initial commit # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # new file:.bowerrc # new file:.editorconfig # new file: Gruntfile.js # new file: app/.htaccess # new file: app/404.html # new file: app/favicon.ico # new file: app/index.html...
7
How do I commit my files? Save your changes with git commit $>git commit [master (root-commit) 645e836] Initial Commit Committer: yule <yule@cs.dal.ca> 19 files changed, 1564 insertions(+), 0 deletions(-) create mode 100644.bowerrc create mode 100644.editorconfig create mode 100644.gitignore create mode 100644.jshintrc create mode 100644 Gruntfile.js create mode 100644 app/.htaccess create mode 100644 app/404.html create mode 100644 app/index.html...
8
How do I update and commit? Edit your files Stage your changes Commit them Combine both using git commit -a $> $> $> vi app/index.html git add app/index/html git commit -m "Made app awesome" [master 4acef2f] Made app awesome Committer: yule <yule@cs.dal.ca> 1 files changed, 1 insertions(+), 0 deletions(-)
9
What about removing files? Can’t just delete the file Have to use git rm Or use git commit -a $> $> rm app/favicon.ico git status # On branch master # Changed but not updated: # (use "git add/rm <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # deleted: app/favicon.ico # no changes added to commit (use "git add" and/or "git commit -a") $> $> git rm app/favicon.ico rm 'app/favicon.ico' git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: app/favicon.ico
10
How do branches work? Create using git branch Change working tree with git checkout Combine with git merge $> $> $> $> $> git branch sweet git branch * master sweet git checkout sweet Switched to branch 'sweet‘ vi Gruntfile.js git commit -a -m "Added ownership" [sweet 43bcbd5] Added ownership Committer: yule <yule@cs.dal.ca> 1 files changed, 2 insertions(+), 0 deletions(-) $> $> git checkout master Switched to branch 'master' git merge sweet Updating 4acef2f..43bcbd5 Fast-forward Gruntfile.js | 2 ++ 1 file changed, 2 insertions(+), 0 deletions(-)
11
How can I share my changes? Update from a remote repo using git pull Send changes using git push git pull remote: Counting objects: 7, done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 3), reused 0 (delta 0) Unpacking objects: 100% (4/4), done. From remote/gitdemo 4acef2f..43bcbd5 master -> origin/master 4acef2f..43bcbd5 sweet -> origin/sweet Updating 4acef2f..43bcbd5 Fast-forward Gruntfile.js | 2 ++ app/favicon.ico | Bin 4286 -> 0 bytes 2 files changed, 2 insertions(+), 0 deletions(-) delete mode 100644 app/favicon.ico $>vi package.json git commit -a -m "Hello" [master 2bc6f5f] Hello Committer: yule <yule@cs.dal.ca> 1 files changed, 1 insertions(+), 1 deletions(-) git push Counting objects: 5, done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 309 bytes, done. Total 3 (delta 2), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. To remote 43bcbd5..2bc6f5f master -> master $> $> $>
12
Other points You can create a file called.gitignore that lists file extensions git won’t include To create a local copy of a repository, use git clone
13
Exercise 1.Install Git 2.Go to https://github.com/dyule/cscsi3130Exercisehttps://github.com/dyule/cscsi3130Exercise 3.Clone the repo 4.Make a branch 5.Make a change to that branch 6.Commit your change
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.