git
Posted Zhou Simon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git相关的知识,希望对你有一定的参考价值。
此文有转载有原创,如有侵权,联系管理员
这里只总结git 作为client的用法, 有机会再总结作为server端的搭建 (ubuntu)
1: 安装
sudo apt-get install git
git --version // check
2: clong
eg:
1: creat git storage
- mkdir test
- cd test
- git init
[email protected]:/home# mkdir test
[email protected]:/home# cd test
[email protected]:/home/test# ls -la
total 8
drwxr-xr-x 2 root root 4096 Sep 8 12:32 .
drwxr-xr-x 14 root root 4096 Sep 8 12:32 ..
[email protected]:/home/test# git init
Initialized empty Git repository in /home/test/.git/
[email protected]:/home/test# ls -la
total 12
drwxr-xr-x 3 root root 4096 Sep 8 12:33 .
drwxr-xr-x 14 root root 4096 Sep 8 12:32 ..
drwxr-xr-x 7 root root 4096 Sep 8 12:33 .git
[email protected]:/home/test# more .git/
branches/ config description HEAD hooks/ info/ objects/ refs/
[email protected]:/home/test# more .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[email protected]:/home/test# tree
.
0 directories, 0 files
[email protected]:/home/test# tree -a
.
└── .git
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
10 directories, 13 files
2: clone
[email protected]:/home/test# git clone --help
NAME git-clone - Clone a repository into a new directory
SYNOPSIS
git clone [--template=<template_directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-b <name>] [-u <upload-pack>] [--reference <repository>]
[--dissociate] [--separate-git-dir <git dir>]
[--depth <depth>] [--[no-]single-branch]
[--recursive | --recurse-submodules] [--] <repository>
[<directory>]
EXAMPLES
· Clone from upstream:
$ git clone git://git.kernel.org/pub/scm/.../linux.git my-linux
$ cd my-linux
$ make
· Make a local clone that borrows from the current directory, without checking things out:
$ git clone -l -s -n . ../copy
$ cd ../copy
$ git show-branch
· Clone from upstream while borrowing from an existing local directory:
$ git clone --reference /git/linux.git \
git://git.kernel.org/pub/scm/.../linux.git \
my-linux
$ cd my-linux
· Create a bare repository to publish your changes to the public:
$ git clone --bare -l /home/proj/.git /pub/scm/proj.git
3: 基本用法:
- git基本命令
- git 分支管理
- 查看日志版本
- 标签
- 提取远程仓库代码
- git分支
4: 使用的一些技巧
- 如果一个文件不小心被删除了,可以有两种方法恢复:
- 想从server 删掉,但是本地想保存,继续用
以上是关于git的主要内容,如果未能解决你的问题,请参考以下文章