• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Git使用
 

Git使用

on

  • 1,718 views

GIT使用简介

GIT使用简介

Statistics

Views

Total Views
1,718
Views on SlideShare
1,718
Embed Views
0

Actions

Likes
4
Downloads
19
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />
  • <br />

Git使用 Git使用 Presentation Transcript

  • git davidx <mykingheaven@gmail.com>
  • git • SCM • • •
  • svn 较
  • GIT
  • 仓库 davidx-laptop:Projects davidx$ mkdir test davidx-laptop:Projects davidx$ cd test davidx-laptop:test davidx$ git init Initialized empty Git repository in /Users/davidx/Projects/test/.git/ davidx-laptop:test davidx$
  • 进 仓库 davidx-laptop:test davidx$ touch README davidx-laptop:test davidx$ git add README davidx-laptop:test davidx$ git add test2/ davidx-laptop:test davidx$ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # # new file: README # new file: test2/file1 # new file: test2/file2 # new file: test2/file3
  • davidx-laptop:test davidx$ git commit -m "init commit" [master (root-commit) e55ac19] init commit 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 README create mode 100644 test2/file1 create mode 100644 test2/file2 create mode 100644 test2/file3
  • 历 davidx-laptop:test davidx$ git log commit e55ac19e882cc3c931f2d844df14578c8109af8e Author: davidx <mykingheaven@gmail.com> Date: Tue Sep 21 15:35:59 2010 +0800 init commit
  • 删 davidx-laptop:test davidx$ git rm test2/file1 rm 'test2/file1' davidx-laptop:test davidx$ git rm test2/file2 test2/file3 rm 'test2/file2' rm 'test2/file3' davidx-laptop:test davidx$ git commit -m "delete some files" [master 458781d] delete some files 0 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test2/file1 delete mode 100644 test2/file2 delete mode 100644 test2/file3
  • 销 davidx-laptop:test davidx$ git checkout README
  • • git reset SHA1 • git reset HEAD~1
  • clone • git clone <git_url> <local_directory>
  • davidx-laptop:test davidx$ git usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [--help] COMMAND [ARGS] The most commonly used git commands are: add Add file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink pull Fetch from and merge with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index show Show various types of objects status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG See 'git help COMMAND' for more information on a specific command.
  • git 级
  • • push • pull
  • branch • GIT • 应该 • 结 , 应该merge
  • branch • : git branch <branch name> • 换 : git checkout <branch name> • -- 换 该 : git checkout -b <branch name>
  • branch davidx-laptop:test davidx$ git branch new davidx-laptop:test davidx$ git checkout new Switched to branch 'new' davidx-laptop:test davidx$ git branch master * new davidx-laptop:test davidx$ git checkout -b new2 Switched to a new branch 'new2' davidx-laptop:test davidx$ git branch master new * new2
  • branch • : git branch • 删 : git branch -d <branch name> • master • 删
  • branch • : git merge <source branch name> • 标 为
  • branch davidx-laptop:test davidx$ git checkout new2 Switched to branch 'new2' davidx-laptop:test davidx$ touch new_file_2 davidx-laptop:test davidx$ git add new_file_2 davidx-laptop:test davidx$ git commit -a [new2 e69c6a9] new file: new_file_2 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 new_file_2 davidx-laptop:test davidx$ git checkout master Switched to branch 'master' davidx-laptop:test davidx$ git merge new2 Updating cb88fd0..e69c6a9 Fast-forward 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 new_file_2
  • tag • 态 标 • branch • 为version发
  • tag davidx-laptop:test davidx$ git tag davidx-laptop:test davidx$ git tag 1.0 davidx-laptop:test davidx$ git tag 1.0
  • 问题
  • 问题 Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com If the identity used for this commit is wrong, you can fix it with: git commit --amend --author='Your Name <you@example.com>'
  • GITCONFIG • ~/.gitconfig • [user] section • name=XXXX • email=XXXX@YYY.ZZZ
  • GITCONFIG [user] name = davidx email = mykingheaven@gmail.com [core] editor = vim