Adds commits from your branch to remote repository

This preview shows page 13 - 24 out of 27 pages.

adds commits from your branch to remote repository repository-name Can set defaults, e.g. git push -u origin master then run git push git remote lets you give names to other repositories Note git clone sets origin to be name for cloned repository
Image of page 13
Git Fetch/Pull git fetch repository-name branch adds commits from branch in remote repository repository-name Usually git pull - combines fetch and merge
Image of page 14
Example: Git & conflicts $ git init /home/cs2041 Initialized empty Git repository in /home/cs2041/.git/ $ git add main.c $ git commit main.c Aborting commit due to empty commit message. $ git commit main.c -m initial [ master ( root-commit ) 8c7d287 ] initial 1 files changed, 1 insertions ( + ) , 0 deletions ( - ) create mode 100644 main.c
Image of page 15
Example: Git & conflicts Suppose Fred does: $ cd /home/fred $ git clone /home/cs2041/.git /home/fred Cloning into /home/fred... done . $ echo >fred.c $ git commit -m ’created fred.c’
Image of page 16
Example: Git & conflicts Suppose Jane does: $ cd /home/jane $ git clone /home/cs2041/.git /home/jane Cloning into /home/jane... done . $ echo ’/* Jane Rules */’ >>main.c $ git commit -a -m ’did some documentation’ [ master 1eb8d32 ] did some documentation 1 files changed, 1 insertions ( + ) , 0 deletions ( - )
Image of page 17
Example: Git & conflicts Fred can now get Jane’s work like this: $ git pull /home/jane/.git remote: Counting objects: 5 , done . remote: Total 3 ( delta 0) , reused 0 ( delta 0) Unpacking objects: 100 % (3 /3 ) , done . From /home/jane/.git * branch HEAD -> FETCH_HEAD Merge made by recursive. main.c | 1 + 1 files changed, 1 insertions ( + ) , 0 deletions ( - )
Image of page 18
Example: Git & conflicts And Jane can now get Fred’s work like this: $ git pull /home/fred/.git remote: Counting objects: 7 , done . remote: Compressing objects: 100 % (4 /4 ) , done . remote: Total 5 ( delta 0) , reused 0 ( delta 0) Unpacking objects: 100 % (5 /5 ) , done . From /home/fred/.git * branch HEAD -> FETCH_HEAD Updating 1eb8d32..63af286 Fast-forward fred.c | 1 + 1 files changed, 1 insertions ( + ) , 0 deletions ( - ) create mode 100644 fred.c
Image of page 19
Example: Git & conflicts But if Fred does this: $ echo ’// Fred Rules’ >fred.c $ git commit -a -m ’added documentation’ And Jane does this: $ echo ’// Jane Rules’ >fred.c $ git commit -a -m ’inserted comments’
Image of page 20
Example: Git & conflicts When Fred tries to get Jane’s work: $ git pull /home/jane/.git remote: Counting objects: 5 , done . remote: Compressing objects: 100 % (2 /2 ) , done . remote: Total 3 ( delta 0) , reused 0 ( delta 0) Unpacking objects: 100 % (3 /3 ) , done . From ../jane/ * branch HEAD -> FETCH_HEAD Auto-merging fred.c CONFLICT ( content ) : Merge conflict in fred.c Automatic merge failed; fix conflicts and then commit the r $ git mergetool
Image of page 21
Example: making Git Repository Public via Github Github popular repo hosting site (see competitors e.g. bitbucket) Github free for small number of public repos Github and competitors also let you setup collaborators, wiki, web pages, issue tracking Web access to git repo e.g.
Image of page 22
Example: making Git Repository Public via Github
Image of page 23
Image of page 24

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture