Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.



How to use Git,and Why

Ruby Ho

on 26 October 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Git

Why Version Control
Svn & Git
Basic Command
Remote Server & Email Notification Concept Basic Command Install Git
Git Basic Command
Branch Why Version Control Git Join Git Club Snapshot,not difference
Nearly Operation Is Local
Git Has Integrity
Only Adds Data
The Three States $ sudo apt-get install git-core Git Install&Setup Install Set Your Account $ git config --global user.name "rubyho"
$ git config --global user.email ruby.ho@mic.com.tw for specific projects , you can run this command without the
--global option when you're in that project. Checking Your Settings $ git config --list $ git config user.name go to the project's directory and type this command to initialize
a repository Git Start Basics $git init $ git status #view your staged and unstaged changes Tracking New Files
$ git add *.c
$ git add README We want to edit fifth.c so now you need to Stage Modified Files
$ git add fifth.c Unstaged staged Committing Your Changes
$ git commit -m 'modify fifth.c & first commit' Viewing The Commit History
$ git log Tracking New Files

Staging Modified Files

Committing Your Changes Now if we want to rename the file from first.c to Sixth.c
$ git mv first.c to sixth.c and we don't want this file(deleted from disk)
$ git rm sixth.c Or you just want to untracked file not deleted from disk
$ git rm --cached second.c $ git commit -m 'delete sixth.c & third comm'
after we commit and realize one forgotten file should be added , so we need to go back to last commit
$ git forgotton_file add
$ git commit --amend You can change your commit message here type $ git log and you'll see commit message changed How about staged files ? If you want to unstage.
Now we modify third.c and staged it. $ git reset HEAD third.c You did some changes with third.c ,but you want to unmodified it, No problem,type this command below.
$ git checkout -- third.c
You'll see "Changed but not updated" has be gone. Maybe you'll have this question , what have you changed but not staged yet ?
First we modify fifth.c & README ,and staged fifth.c
You'll see this below. type $ git diff You see the changes in unstaged file README type $ git diff --cached You see the changes in staged file fifth.c Finally, you can use the friendly GUI to know what have we done.
$ gitk Tagging We can use tags after your commit to specific points in history Now let's creating tags.
$ git tag -a v1.1 -m 'My Version V1.1' # -a tag name ; -m tag message
and shows the tagger detail information
$ git show v1.1 If you want to tag the commit of history,what can we do ?
$ git log --pretty=oneline and we want to tag babf75 this commit
$ git tag -a v1.3 babf75
$ git show v1.3 Now let's see what tags did we make ?
$ git tag Branch Create a new branch
$ git branch develope or git checkout -b develope #Create & checkout See what branch do you have
$ git branch the star means which branch are you working on now Svn & Git What Difference Between SVN & Git
How to make
SVN & Git Together Remote Server
&Email Notification File ://
Email Notification Merge Assume we committed on develope branch,now we have to merge it into master.
$ git checkout master
$ git merge develope Delete the branch
$ git branch -d develope # if you want to delete the branch that
you have not merge it, you should use -D Conflicats
You have solve this problem by yourself,use commands below to help you do it. $ git branch - v #You can see the last commit on each branch
$ git branch --merged
$ git branch --no-merged #To see all branches which is merged or not on the branch that you work on. Rebasing you can take all the changes that were committed on one branch and replay them on another one. $ git checkout experiment
$ git rebase master
Do not rebase commits that you have pushed to a public repository, or every body 'll hate you. Add Remote Server Local Protocol (cc) image by anemoneprojectors on Flickr This command will copy all remote_repository to your disk.
$ git clone /your/path/
or you just want to add exsiting repository.
$ git remote add [name] /your/path The Http Protocol What Difference Between
Git & SVN Git sVN Distributed Centralized Log on local Log on web $ cd /var/www/htdocs/
$ git clone --bare /home/rubyho/server3 httpserver3.git
$ cd httpserver3.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod a+x hooks/post-update Email Notification 1. /usr/share/doc/git-core/contrib/hooks/
2.$ chmod a+x post-receive-email
3.$ ln -sf /usr/share/doc/git-core/contrib/hooks/post/receive-email/
your-project's path.git/hooks/post-receive
4. cd your project's path.git/hook/
5.$ chmod a+x post-receive
6. cd ..
7.$ git config --add hooks.mailinglist "Email"
8.$ vim config #will show what are you setting
9.$ git config hooks.emailprefix [project name]
10.cd description
11. vim description #set detail of mail Share With Everyone When you are ready to share your code with everyone.
$ git push [remote_name][branch-name]
when you would like to know
$ git pull
The command goes out to that remote project and pulls down all the data from that remote project that you don’t
have yet.
$ git fetch [remote-name]
It'll show you about remote repository information
$ git remote show [remote-name]
If you want to remove the remote repository
$ git remote rm [remote-name] If you have remote repository,you can use these command to update with remote repository. Less storage
Space How To Make Git & Svn Together 1.install git-svn
$ sudo apt-get install git-svn
2.Assume I already have my own svn repository,and now you want to join it.
$ git svn clone --stdlayout
file:///tmp/test/hello hello-git Due to use stdlayout ,so that tag/branch will be automatic
correspond to remote branch You find out that my Program can't compile,so you begin to edit file,after edited,you use $ git add -p command to pick up which part of repository will be commit and the others will be stash,final, use
$ git svn dcommit commit to my svn repository Few days later,I find out that you has updated,so I need to do synchronous,
at the same time,I have a local branch master, after I update branch master,I
need to make fancy branch and master rebase. $ git svn fetch
M hello.c
r6 = c43134a98f43dc6507deaa7495bfcd2c906aaa30 (trunk)
$ git svn rebase
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/trunk.
$ git checkout fancy
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Inital fancy output branch The End Screw Things up
Revert Files Back
Compare Changes
Develope New Feature More Storage Space Follow these steps
Full transcript