Untitled - MYY web server
Transcription
Untitled - MYY web server
Outline Who is behind Deveo? Introduction to Version Control Systems Basics of Git Demo Exercises Who is behind Deveo? Eficode in brief Founded in 2005, privately owned 80 employees Offices in Helsinki, Beijing, and Copenhagen ISO 9001:2008 certified management system AAA-credit rating How to manage source code? Why Version Control (VCS)? VCS manages changes to documents, source code, etc. – time machine VCS allows a group of people to simultaneously collaborate on the same files - feedback VCS may act as a disaster recovery strategy - backup Centralized VS Distributed Central repository on a server Send/receive changes from the central server Single point of failure Every developer has own mirror of repository Send/receive changes to own repository Continue working offline and share changes later Git is a Distributed VCS with an emphasis on speed - fast Speed Simple design Network independent Strong support for non-linear development Fully distributed Efficiently handles large projects Open source Git VS “other systems” Version 1 file A Version 2 1 file B Version 3 2 1 Snapshots – not Differences Version 1 Version 2 Version 3 file A file A2 file A3 file B file B file B1 snapshot Nearly every Git operation is local Git guarantees data integrity 74262eab53b5f3ee4d578e484436e1ca72c57625 working directory staging area git repository The three local states of Git checkout the sources stage files commit Installing and configuring Git http://progit.org/book/ch1-4.html $ git config --global user.name "Tair Assimov" $ git config --global user.email "[email protected]" Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Initializing $ git init $ touch README $ git add README $ git commit -m 'initial project version' Basic Workflow: Cloning $ git clone https://emea.deveo.com/eficode/git/project $ git clone [email protected]:eficode/git/project $ git clone /var/db/eficode/git/project Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Modify $ mate hello_git.rb $ echo "A Hello Git program" >> README #!/usr/bin/env ruby class HelloGit def initialize(git = '/usr/bin/git') @git = git end def to_s "Hello, from #{%x[#{@git} --version]}!" end end hello = HelloGit.new puts hello.to_s working directory staging area git repository Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Browse $ git status # On branch master # Changes not staged for commit: # # modified: README # # Untracked files: # # hello_git.rb no changes added to commit (use "git add" and/or "git commit -a") Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Stage $ git add hello_git.rb working directory # On branch master # Changes to be committed: # # new file: hello_git.rb # # Changes not staged for commit: # # modified: README staging area git repository Basic Workflow: Stage $ git add . working directory $ git status # On branch master # Changes to be committed: <- STAGED # # modified: README # new file: hello_git.rb staging area git repository Basic Workflow: Unstage $ touch temp.swp working directory $ git add . $ git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: temp.swp $ git reset HEAD temp.swp staging area git repository Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Save $ git commit working directory staging area git repository [master 1bfac9e] Descriptive summary of a commit 2 files changed, 17 insertions(+), 0 deletions(-) create mode 100755 hello_git.rb Hold on, what was that number? [master 1bfac9e] 1bfac9eacb671e7916b64c5680c37264e1413ac0 $ git log commit 1bfac9eacb671e7916b64c5680c37264e1413ac0 Author: Tair Assimov <[email protected]> Date: Mon Apr 23 19:22:01 2012 +0300 Descriptive summary of a commit... Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Modify and Browse $ mate README $ git diff diff --git a/README b/README index 5710088..830c0c7 100644 --- a/README +++ b/README @@ -1 +1,2 @@ -A Hello Git program +A Hello Git program to print out version +of the Git binary. working directory staging area git repository Browse status log diff Create init clone Modify vim mate Basic workflow Save commit Stage add reset Sync push pull Basic Workflow: Stage and Commit $ git status # # # # On branch master Changes not staged for commit: modified: README $ git commit -a -m "Update README" [master 2b1e925] Update README 1 files changed, 2 insertions(+), 1 deletions(-) working directory staging area git repository More Git goodies… Ignoring files Ignoring files == Not tracking with Git Ignore temporary files, sensitive files Create .gitignore file in the root of the project Standard blob patterns work Ignoring files $ cat .gitignore # this is a comment *~ # ignore all files that end with tilde *.swp # ignore all files with .swp extension !t.swp # but track t.swp /tmp # ignore /tmp file or directory doc/*.txt # ignore doc/notes.txt, but not doc/server/arch.txt Removing files without Git $ rm README $ git status # Changes not staged for commit: # # deleted: README $ git add -u $ git status # Changes to be committed: # # deleted: README Removing files with Git $ git rm README $ git status # On branch master # Changes to be committed: # # deleted: README Removing files / Untracking $ git rm --cached README $ git status # On branch master # Changes to be committed: # # deleted: README # # Untracked files: # # README Moving files without Git $ mv README README.txt $ git status # On branch master # Changes to be committed: # # deleted: README # # Untracked files: # # README Moving files with Git $ git mv README README.txt $ git status # On branch master # Changes to be committed: # # renamed: README -> README.txt Viewing Commit History $ git log -p $ git log -stat $ git log --pretty=oneline $ git log --since=1.day $ git log --pretty=oneline --author=Tair --since=1.week Undoing things - Amending $ git commit -m 'initial commit’ $ git add forgotten_file $ git commit --amend Undoing things - Unmodifying $ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: hello_git.rb $ git checkout -- hello_git.rb Browse status log diff Create init clone Modify vim mate Git remotes Save commit Stage add reset Sync push pull VCS allows a group of people to simultaneously collaborate on the same files - feedback Online project hosting Hosting tools streamline collaborative development Find, publish, and contribute to Open Source software Reliable, robust and backed up Deveo is a software development platform, which collects information into one, easily accessible place Version control Task management Continuous Integration Executive Documentation Project Manager Testing Communication Developers Demo Cloning existing repository $ git clone https://emea.deveo.com/.../git/repo Cloning into repo... remote: Counting objects: 10, done. remote: Compressing objects: 100% (7/7), done. remote: Total 10 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (10/10), done. Showing remotes $ git remote origin $ git remote –v originhttps://emea.deveo.com/.../git/repo (fetch) originhttps://emea.deveo.com/.../git/repo (push) another [email protected]:eficode/.../git/repo Adding remote $ git remote add origin https://emea.deveo.com/.../git/repo $ git remote add upstream https://emea.deveo.com/.../git/repo Fetching and Pulling from remotes $ git fetch another From https://emea.deveo.com/.../git/repo * [new branch] $ git pull master -> another/master Pushing changes to remote $ git push origin master Removing and renaming remotes $ git remote rename another another_origin $ git remote another_origin origin $ git remote rm another_origin $ git remote origin Branching and Merging What is a Branch? Branch in Git is a lightweight movable pointer to one of the commits master commit 1 commit 2 commit 3 What if you create a new Branch? $ git branch feature master commit 1 commit 2 commit 3 feature Where are you now? HEAD master commit 1 commit 2 commit 3 feature Switch to a branch $ git checkout feature $ git checkout -b feature # creates a branch and switches to it master commit 1 commit 2 commit 3 feature HEAD Commit to feature branch $ git commit -a -m "New feature. Initial commit" master commit 1 commit 2 commit 3 commit 4 feature HEAD Checkout master $ git checkout master HEAD commit 1 commit 2 master commit 3 commit 4 feature Commit to master $ git commit -a -m "Master diverged" HEAD commit 1 commit 2 commit 3 master commit 5 commit 4 feature Getting Help http://progit.org [email protected]