Slide 1

Slide 1 text

1 / 41 an introduction and :

Slide 2

Slide 2 text

2 / 41 Distributed. SVN

Slide 3

Slide 3 text

3 / 41 Distributed. Git

Slide 4

Slide 4 text

4 / 41 Fast. Committing and pushing code: 2164+, 2259- git: 0.64 s SVN: 2.60 s Committing and pushing 1000, 1k images git: 1.53 s SVN: 24.70 s Viewing the log of the last 50 commits git: 0.01 s SVN: 0.38 s

Slide 5

Slide 5 text

5 / 41 Staging area. Index Repository git add git commit

Slide 6

Slide 6 text

6 / 41 Let's start a repository.

Slide 7

Slide 7 text

7 / 41 $ git clone $ git clone https://github.com/networkdynamics/zenlib zen

Slide 8

Slide 8 text

8 / 41 $ git init $ git init $ git remote add origin https://github.com/networkdynamics/zenlib

Slide 9

Slide 9 text

9 / 41 $ git status # On branch master # # Initial commit # nothing to commit (create/copy files and use "git add" to track)

Slide 10

Slide 10 text

10 / 41 $ git add $ echo "Under construction" > README $ git add readme

Slide 11

Slide 11 text

11 / 41 $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached ..." to unstage) # # new file: README #

Slide 12

Slide 12 text

12 / 41 $ git diff $ git diff $ echo "Coming soon" > README $ cat README Coming soon Staging area (index) vs working tree (filesystem)

Slide 13

Slide 13 text

13 / 41 $ git diff diff --git a/README b/README index 03b5361..3c0b0b0 100644 --- a/README +++ b/README @@ -1 +1 @@ -Under construction +Coming soon

Slide 14

Slide 14 text

14 / 41 $ git commit $ git commit -m "Add under construction message" [master (root-commit) c841ccc] Add under construction message 1 file changed, 1 insertion(+) create mode 100644 README Filesystem -> Staging area only

Slide 15

Slide 15 text

15 / 41 $ git show Shows the last commit (or any commit, or a tag, etc)

Slide 16

Slide 16 text

16 / 41 $ git show commit c841cccbdfdc3dbc9e5333695e492a0a2fafdfa0 Author: dellsystem Date: Tue Aug 7 13:41:03 2012 -0400 Add under construction message diff --git a/README b/README new file mode 100644 index 0000000..03b5361 --- /dev/null +++ b/README @@ -0,0 +1 @@ +Under construction

Slide 17

Slide 17 text

17 / 41 $ git checkout Discard changes in working directory $ cat README Coming soon $ git checkout README $ cat README Under construction

Slide 18

Slide 18 text

18 / 41 $ git commit --amend Change the last commit $ echo "Under construction!" > README $ cat README Under construction! $ git add README $ git commit --amend

Slide 19

Slide 19 text

19 / 41 $ echo "Under construction!" > README $ cat README Under construction! $ git add README $ git commit --amend

Slide 20

Slide 20 text

20 / 41 1 Add "Under construction!" message 2 3 # Please enter the commit message for your changes. Lines starting 4 # with '#' will be ignored, and an empty message aborts the commit. 5 # On branch master 6 # 7 # Initial commit 8 # 9 # Changes to be committed: 10 # (use "git rm --cached ..." to unstage) 11 # 12 # new file: README 13 #

Slide 21

Slide 21 text

21 / 41 $ git log Show the log of all commit activity $ git log commit 76942d9c793578979e9cd6465f15b13e41d13d29 Author: dellsystem Date: Tue Aug 7 13:41:03 2012 -0400 Add "Under construction!" message

Slide 22

Slide 22 text

22 / 41 $ git reset $ echo "Will be ready September 1." >> README $ cat README Under construction! Will be ready September 1. $ git add . $ git status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: README #

Slide 23

Slide 23 text

23 / 41 $ git reset HEAD README Unstaged changes after reset: M README $ git status # On branch master # Changes not staged for commit: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: README # no changes added to commit (use "git add" and/or "git commit -a")

Slide 24

Slide 24 text

24 / 41 $ git add --patch Selectively committing changes in a file

Slide 25

Slide 25 text

25 / 41 def extract_feature(self, user): user_name = self.get_data(user) # Make it upper case and take everything before the first space first_name = user_name.upper().split()[0] value = self.data.get(first_name, 0.0) log.debug("%s: %.3f" % (first_name, value)) - return [vlaue] + return [value] ... +#================================ +# Actual features below +#================================ class NaiveWords(NaiveFeature): feature = 'words' class NaiveDigrams(NaiveFeature): } want } do not want

Slide 26

Slide 26 text

26 / 41 $ git add --patch features.py [...] - return [vlaue] + return [value] Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? y [...] +#================================ +# Actual features below +#================================ Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? q -> yes, stage this hunk -> no, and quit

Slide 27

Slide 27 text

27 / 41 $ git branch master (stable) bugfix awesomenewfeature

Slide 28

Slide 28 text

28 / 41 $ git branch Or, any other workflow. master develop master somebranch anotherbranch etc

Slide 29

Slide 29 text

29 / 41 $ git push Pushing your changes to a server $ git push origin master -u

Slide 30

Slide 30 text

30 / 41 $ git push origin master -u # On branch master # Your branch is ahead of 'origin/master' by 1 commit. Branch tracking

Slide 31

Slide 31 text

31 / 41 $ git pull Keeping your local copy up-to-date $ git pull

Slide 32

Slide 32 text

32 / 41 Merge conflicts

Slide 33

Slide 33 text

33 / 41 Rebasing Rewording commit messages Reordering commits Combining commits and more!

Slide 34

Slide 34 text

34 / 41 Rebasing $ git rebase -i HEAD~5 The last 5 commits

Slide 35

Slide 35 text

35 / 41 Aliasing $ git s -> status $ git d -> diff $ git p -> add --patch

Slide 36

Slide 36 text

36 / 41 Multiple remote branches

Slide 37

Slide 37 text

37 / 41 Whitespace problems this line has trailing whitespace

Slide 38

Slide 38 text

38 / 41 Tagging $ git tag v1.0.0 -m "First gold release"

Slide 39

Slide 39 text

39 / 41 Bisecting

Slide 40

Slide 40 text

40 / 41 Git resources https://help.github.com/ Pro Git (http://git-scm.com/book) Git man pages (git help, git add help)

Slide 41

Slide 41 text

41 / 41 Github issues :: pull requests :: comparison view :: commit view :: blame :: history :: wiki :: markdown