1 / 13

Git

Git. What’s G it ?. A B ritish swear A Distributed Version C ontrol S ystem 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. How does G it work?.

argyle
Télécharger la présentation

Git

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. How does Git work? commit • Maintains a repository of changes to a folder • The directory can be “saved” (committed) or “opened” (checked out) at any version Working Tree checkout Repository 1 1 2 0ef19fe14ce b a b 997bf04ea5 5f7b5ac909 i i i α 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 Repository push 0ef19fe14ce 997bf04ea5 282bd722f 5f7b5ac909 Other Repository 360acfe22

  5. How do I start with Git? • Install it • Command line • GUI version • Create a new repo with gitinit $> $> ls app bower.jsoncss Gruntfile.js imgjsnode_modulespackage.json test gitinit 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 add . gitstatus # On branch master # Initial commit # Changes to be committed: # (use "gitrm --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 ... gitstatus # 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) $> $>

  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 gitrm • Or use git commit -a rmapp/favicon.ico gitstatus # 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") gitrm app/favicon.ico rm 'app/favicon.ico' gitstatus # 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 gitbranch sweet gitbranch * master sweet gitcheckout 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(-) gitcheckout master Switched to branch 'master' gitmerge 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(-) gitpush 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 • Install Git • Go to https://github.com/dyule/cscsi3130Exercise • Clone the repo • Make a branch • Make a change to that branch • Commit your change

More Related