Linux 文件属性读取

简单说一下

使用 stat 函数,通过文件的绝对路径或者相对路径的文件名去打开相应文件的属性

包含的头文件

1
#include <sys/stat.h>

参考函数

1
int stat(const char *path, struct stat *buf);

读取文件属性

1
2
3
4
5
6
7
8
9
10
11
...

struct stat *infobuf;

if (stat("/etc/passwd", &infobuf) == -1) {
perror("/etc/passwd");
} else {
printf("The size of /etc/passwod is %d\n", infobuf.st_size);
}

...

stat 结构

Linux 目录操作

简单说明一下

目录是文件的列表,在Linux下对于目录来说是有系统调用可以使用来操作目录的。

目录的操作需要一个目录文件绝对路径或者当前目录的相对路径。

目录操作的大概过程为:打开目录,读取目录内容放入目录的结构体里面,然后对于结构体的数据进行呈现,最后不需要的时候关闭目录。

打开目录,会得到一个打开的目录文件描述符 DIR (一个无符号整数),读取目录内容需要目录的文件描述符.

DIR 作为 打开目录的文件描述符的宏参数


open

  • 函数参考
    1
    DIR *opendir(const char *name); /* name: 目录的绝对路径或者相对路径 */
  • 开始打开文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    /**
    使用该函数打开目录,返回的目录文件描述符可以用于读取目录内容。

    */
    ...
    DIR *dir_ptr ; /* 目录文件描述符指针 */

    if ((dir_ptr = opendir("/")) == NULL) { /* 打开目录 */
    fprintf(stderr, "something error: %s", name);
    }
    ...

read

  • 函数参考

    1
    2
    int readdir(unsigned int fd, struct old_linux_dirent *dirp,
    unsigned int count);
  • 开始读取目录内容

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    /**
    使用该目录文件描述符,读取目录文件的内容,放入结构体指针中。

    */
    ...
    struct dirent *direntp; /* 目录结构体指针 */

    while ((direntp = readdir(dir_ptr)) != NULL) { /* 读取存入结构体 */
    printf("%s\n", direntp->d_name);
    }
    ...

    dirent 结构体的内容

close

  • 函数参考

    1
    int closedir(DIR *dirp);
  • 关闭目录

    1
    2
    3
    4
    5
    6
    7
    /**
    使用目录文件描述符关闭目录。

    */
    ...
    closedir(dir_ptr);
    ...

move curser

Linux 文件属性的结构体

从帮助中查信息

1
2
3
4
5
6
7
8
9
10
11
12
$ man -k file | grep -i status
fileno [ferror] (3) - check and reset stream status
fstat (3p) - get file status
fstatat (2) - get file status relative to a directory file descriptor
fstat [stat] (2) - get file status
lstat [stat] (2) - get file status
stat (1) - display file or file system status
stat (2) - get file status
stat (3p) - get file status

$ man 2 stat
...(内容省略)

文件结构体所在的头文件

  • sys/stat.h
    1
    #include <sys/stat.h>

文件结构体

  • 结构体 - stat
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    struct stat {
    dev_t st_dev; /* ID of device containing file */
    ino_t st_ino; /* inode number */
    mode_t st_mode; /* protection */
    nlink_t st_nlink; /* number of hard links */
    uid_t st_uid; /* user ID of owner */
    gid_t st_gid; /* group ID of owner */
    dev_t st_rdev; /* device ID (if special file) */
    off_t st_size; /* total size, in bytes */
    blksize_t st_blksize; /* blocksize for file system I/O */
    blkcnt_t st_blocks; /* number of 512B blocks allocated */
    time_t st_atime; /* time of last access */
    time_t st_mtime; /* time of last modification */
    time_t st_ctime; /* time of last status change */
    };

Linux 目录内容的结构

从帮助中查信息

1
2
3
4
5
6
7
8
9
10
11
$ man -k direct | grep read
readdir (2) - read directory entry
readdir (3p) - read a directory
readdir (3) - read a directory
readdir_r [readdir] (3p) - read a directory
readdir_r [readdir] (3) - read a directory
readlinkat (2) - read value of a symbolic link relative to a directory file descriptor
seekdir (3) - set the position of the next readdir() call in the directory stream

$ man 3 readdir
...(内容省略)

目录结构所在的头文件

  • dirent.h
    1
    #include <dirent.h>

保存目录内容的结构体

  • 结构体 - dirent
    1
    2
    3
    4
    5
    6
    7
    8
    struct dirent {
    ino_t d_ino; /* inode number */
    off_t d_off; /* offset to the next dirent */
    unsigned short d_reclen; /* length of this record */
    unsigned char d_type; /* type of file; not supported
    by all file system types */
    char d_name[256]; /* filename */
    };

IOS 本地音乐播放

概述

首先是了解一下 iPod Library Access ,知道本地音乐文件的来源。接着就是知道如何使用播放器的类实例 MPMusicPlayerController ,去播放本地的音乐文件。这样基本就可以了,为了把Apple的文档使用多一些。尝试使用 Media item picker,深入再操作一下 iPod Library.

接触的类有:

  • MPMediaItem
  • MPMusicPlayerController
  • MPMediaQuery

其他参考类

  • MPMediaGroupingAlbum
  • MPMediaLibrary

目录

使用前提醒

需要头文件

1
2
3
4
5
/**
在项目的 `General` 的 `Linked Frameworks and Libraries` 里面加入 `MediaPlayer.framework`
*/

#import <MediaPlayer/MediaPlayer.h> /* 在你需要播放器的文件里加上这个头文件 */

About iPod Library Access

如果你想播放本地的音乐,首先你要知道它存放的位置,iPod Library 就是存放它的地方。

而这个地方也是一个数据库


  • 先看图 Using iPod library access

    然后就是,我们的应用使用 Media Query 去获取 iPod Library 的音乐文件,然后应用交给 Music Player 去播放它们。

    然后在对照上图,就可以大概知道一个情况了。

    了解数据库的状态的改变,这需要 MPMediaLibraryDidChangeNotification 来作为通知。


返回的内容是一个 MPMediaItem 的数组,MPMediaItem 包含了一个媒体文件所有信息。

获取所有的音乐文件,我们还需要一个 MPMediaQuery, 这个类的实例可以用于初始化播放器的播放内容。

1
2
3
MPMediaQuery *mySong = [MPMediaQuery songsQuery]; // 这样我们就可以得到了本地音乐文件的所有内容啦

MPMediaItem *item = [mySong items][0]; // 获取本地音乐文件的第一个文件

想对 MPMediaQuery 有更多的使用有更多的了解
更多关于播放队列


Media playback

  • 播放的一些概念术语 Schematic representation of a music player object

说好的播放器,就需要一个播放器实例啦。那就是 MPMusicPlayerController.

1
2
/* 生成一个播放器的实例 */
MPMusicPlayerController *player = [MPMusicPlayerController applicationMusicPlayer];

但是,有了播放器,还需要播放的文件呢!上面我们的到了播放文件列表的一个 MPMediaQuery 实例。Just do it

1
2
3
4
5
6
[player setQueueWithQuery: [MPMediaQuery songsQuery]];
/**
或者是
[player setQueueWithQuery: mySong];

*/

还没有完哦,如果播放器的播放状态改变了,我们也需要这个消息通知

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
( handle_NowPlayingItemChanged: ) 和 ( handle_PlaybackStateChanged: ) 是自定义的方法。

在注销的时候,记得也把通知给注销掉哦。。。。。
*/
// now playing
[notificationCenter addObserver:self
selector:@selector(handle_NowPlayingItemChanged:)
name:MPMusicPlayerControllerNowPlayingItemDidChangeNotification object:_myPlayer];

// playback state change
[notificationCenter addObserver:self
selector:@selector(handle_PlaybackStateChanged:)
name:MPMusicPlayerControllerPlaybackStateDidChangeNotification object:_myPlayer];

[player beginGeneratingPlaybackNotifications]; // player set the notification

然后就可以开始播放了。。。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
遵循了 `MPMediaPlayback` Delegate,

*/
[player play]; // 播放

[_myPlayer pause]; // 暂停

[_myPlayer stop]; // 停止

[_myPlayer skipToBeginning]; // 重新开始播放

[_myPlayer skipToNextItem]; // 下一首

[_myPlayer skipToPreviousItem]; // 上一首

... (还有一些都在这个实例里面的)

到这里基本就没有了,一个简单的没有界面的播放器就完成了


更多关于 Media Query

  • Using a media query to access the device iPod library Using a media query to access the device iPod library

    上文我们得到的 MPMediaQuery 的实例 mySong.和图中的 myQuery 一样的。

media query 提供了一个对于 iPod Library 的一个搜索描述,告诉数据库如何去获取相应的 media item,并且还有如何组织这些 item

有两个配置属性

- The `filter` is the description of what to retrieve. The filter is optional; a filterless query matches the entire iPod library.

- The `grouping` type is an optional key that specifies the arrangement to use for retrieved collections of media items.

更多关于播放队列

有两种方法去设置播放的队列内容

  • Use a media item collection

    1
    2
    3
    4
    /**
    musicPlayer 是 MPMusicPlayerController 的实例
    */
    [musicPlayer setQueueWithItemCollection: userMediaItemCollection];
  • Use a media query, which implicitly defines a collection

    1
    2
    3
    4
    /**
    musicPlayer 是 MPMusicPlayerController 的实例
    */
    [musicPlayer setQueueWithQuery: [MPMediaQuery songsQuery]];

更多关于使用iPod Library

  • 如何使用更好的使用iPod Library Using the iPod library database access classes
    参考官方文档

关于如何使用item picker

  • 使用 Item Picker  The user interface of the media item picker

Using the Media Item Picker


参考链接信息

iPod Library Access Programming Guide

Media Player Framework Reference

MPMusicPlayerController

MPMediaPlayback

MPMediaLibrary

Man为什么查不到和书上的相似的结果

解决man无法找到你想要的内容

1.安装好 man 后,发现你查询的内容是 No manual entry for ***

原因: 没有安装 man-pages

解决方案

1
$ sudo yum install -y man-pages //如果权限问题,切换到root下

2.man -k {file} | grep {read} 没有结果

原因:本地数据库没有更新

解决方案

1
$ sudo makewhatis //如果权限问题,切换到 root 下

IOS_Storyboard

简介

  • 简单介绍一下 Storyboard ,然后对其进行创建和配置,使得可以最干净(干净的意思是没有任何代码的实现,类似于什么都没有做的一个View)的启动。
  • 然后理解 segue ,对其进行使用
  • 使用 segue 中去传递数据
  • 最后是对于 Storyboard 的一些讨论

Index

  1. Storyboard
  2. 创建和配置 Storyboard
  3. Segue
  4. 传递数据
  5. 讨论 Storyboard

Storyboard

Storyboard is IOS 的一个特性功能, 它可以让你所有的初始化和布局视图控制器(View Controller)在一个类似于 XIB 的文件中。

StoryBoard 是苹果在 iOS 5 中引入的新技术方案,目的是给纷繁复杂的 nibxib 们一个温暖的家,让他们之间的关系更直观地展示出来,并提供了一种新的页面间跳转方式 segue。

StoryBoard 的本质是一个 XML 文件,描述了若干窗体、组件、Auto Layout 约束等关键信息

苹果官方是推荐我们将所有的UI都使用Storyboard去搭建,Storyboard也是一个很成熟的工具了。使用Storyboard去搭建所有界面,我们可以很迅捷地搭建出复杂的界面,也就是说能为我们节省大量的时间。我们还可以很直观地看出各个界面之间的关系,修改起来也很方便。将来如果遇到需要作修改的地方,我们只需要找到相对应的Storyboard就可以了,比起以前来说,快捷了不少。

创建和配置 Storyboard

1.创建一个空工程

>
p_1
>
p_2

2.创建一个StoryBoard

  • 为了能够完全的了解启动的步骤,我们把 Main.storyBoard 删掉
    >
    p_3

  • 删掉后我们来创建一个 StoryBoard
    >
    p_4

  • 命名为 templeStoryboard
    >
    p_5

  • 然后拖一个 Navigation Controller 过来
    >
    p_6

3.配置StoryBoard

  • navigation 作为入口的 controller ,点击 navigationview ,然后设置
    >
    p_7
  • 启动前设置一下 Main interface
    >
    p_8

  • 效果
    >
    p_9

    这个时候,简单的配置就完成了


Segue

  • 拖出两个 View Controller
    >
    p_10

  • 从 table view 那边,按住 Control 键,使用鼠标拖到某一个 view controller
    >
    p_11

  • 松开后就会出现一个列表,选择 push,或者 modal,然后就可以实现简单的事件出发了。

  • 对于 modal 的视图来说没有返回,所以需要代码来使它消失

    1
    2
    [self.presentingViewController dismissViewControllerAnimated:YES
    completion:nil];

传递数据

  • 传递数据,也就是点击事件出发的方法来做到的,segue 的触发会调用这个方法
    1
    2
    3
    4
    5
    6
    7
    /**
    这个方法就是segue点击后触发的方法

    @param segue storyboard的segue
    @param sender 尖头目的指向的类实例
    */
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

讨论 Storyboard

storyboard 在我们看起来挺不错的, 但是并不是非常的有用.

  • 优势

    • Storyboards can be used to easily show off the flow of an application to a client or a colleague.
    • Storyboards remove some simple code from your source files.
    • Tables with static content are easy to create.
    • Prototype cells replace the need to create separate XIBs for custom table view cells.
    • Storyboards sure do look pretty.
  • 劣势

    • Storyboards are difficult to work with in a team. Typically, a team of iOS programmers breaks up the work by having each member focus on a particular view controller. With a storyboard, everyone has to do their work in the same storyboard file. This can quickly lead to clutter and difficulties with version control.
    • Storyboards disrupt the flow of programming. Let’s say you are writing a view controller and adding the code for a button that presents a view controller modally.

      You can do that pretty easily in code – alloc and init the view controller, and send presentViewController:animated:completion: to self. With storyboards, you have to load up the storyboard file, drag some stuff onto the canvas, set the Class in the identity inspector, connect the segue, and then configure the segue.

    • Storyboards sacrifice flexibility and control for ease of use. The work required to add advanced functionality to the basic functionality of a storyboard is often more than the work required to put together the advanced and basic functionality in code.

    • Storyboards always create new view controller instances. Each time you perform a segue, a new instance of the destination view controller is created. Sometimes, though, you would like to keep a view controller around instead of destroying it each time it disappears off the screen. Storyboarding does not allow you to do this.

    Overall, storyboards make easy code easier and difficult code more difficult. We do not use them in this book, and we do not typically use them when writing our own applications. However, Apple seems to be pushing them harder in each release of Xcode, so you might one day decide that a particular application would benefit from storyboarding.

参考链接

AFNetworking学习笔记-1

概览

  • 版本:3.0.4
  • 结构图 > p_afnetworking_inherit

AFNetworking - Serializer

关于 Serializer

看一下它的继承结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

<NSObject>
|
+------------------------------------------+
| |
<AFHTTPRequestSerializer> <AFHTTPResponseSerializer>
| |
+--------+--------+ |
| | |
<AFJSONRequestSerializer> <AFPropertyListRequestSerializer> |
|
|
|
+-------------------------+-----------------------------+-----------------+------------------+
| | | | |
<AFPropertyListResponseSerializer> <AFJSONResponseSerializer> <AFImageResponseSerializer> | <AFXMLParserResponseSerializer>
|
|
|
<AFXMLDocumentResponseSerializer> * (for mac)

了解一下

发送数据和接收数据的序列化编码封装

AFHTTP*

  • AFHTTPRequestSerializer

    AFHTTPRequestSerializer conforms to the AFURLRequestSerialization & AFURLResponseSerialization protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.

    Any request or response serializer dealing with HTTP is encouraged to subclass AFHTTPRequestSerializer in order to ensure consistent default behavior.

  • AFHTTPResponseSerializer

    AFHTTPResponseSerializer conforms to the AFURLRequestSerialization & AFURLResponseSerialization protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation.

    Any request or response serializer dealing with HTTP is encouraged to subclass AFHTTPResponseSerializer in order to ensure consistent default behavior.

AF*RequestSerializer

  • AFJSONRequestSerializer

    AFJSONRequestSerializer is a subclass of AFHTTPRequestSerializer that encodes parameters as JSON using NSJSONSerialization, setting the Content-Type of the encoded request to application/json.

  • AFPropertyListRequestSerializer

    AFPropertyListRequestSerializer is a subclass of AFHTTPRequestSerializer that encodes parameters as JSON using NSPropertyListSerializer, setting the Content-Type of the encoded request to application/x-plist.

AF*ResponseSerializer

  • AFPropertyListResponseSerializer

    AFPropertyListResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes XML responses as an NSXMLDocument objects.

    By default, AFPropertyListResponseSerializer accepts the following MIME types:

    - application/x-plist
    
  • AFXMLParserResponseSerializer

    AFXMLParserResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes XML responses as an NSXMLParser objects.

    By default, AFXMLParserResponseSerializer accepts the following MIME types, which includes the official standard, application/xml, as well as other commonly-used types:

    - application/xml
    - text/xml   
    
  • AFXMLDocumentResponseSerializer

    AFXMLDocumentResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes XML responses as an NSXMLDocument objects.

    By default, AFXMLDocumentResponseSerializer accepts the following MIME types, which includes the official standard, application/xml, as well as other commonly-used types:

    - application/xml
    - text/xml     
    
  • AFJSONResponseSerializer

    AFJSONResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes JSON responses.

    By default, AFJSONResponseSerializer accepts the following MIME types, which includes the official standard, application/json, as well as other commonly-used types:

    - application/json
    - text/json
    - text/javascript
    
  • AFImageResponseSerializer

    AFImageResponseSerializer is a subclass of AFHTTPResponseSerializer that validates and decodes image responses.

    By default, AFImageResponseSerializer accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage:

    - image/tiff
    - image/jpeg
    - image/gif
    - image/png
    - image/ico
    - image/x-icon
    - image/bmp
    - image/x-bmp
    - image/x-xbitmap
    - image/x-win-bitmap
    

开始剖析吧

链接参考

node 安装

关于Node

Node 是一个服务器端 JavaScript 解释器,它将改变服务器应该如何工作的概念。它的目标是帮助程序员构建高度可伸缩的应用程序,编写能够处理数万条同时连接到一个(只有一个)物理机的连接代码。


Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.


安装Node

Node for Mac

  • 安装 Homebrew
    node_install_p_2
    安装Homebrew
  • 安装 node

    1
    2
    3
    $ brew install node
    $ node --version
    v5.5.0

    这样在 Mac 下的 Node 就安装好了

Node for Windows

  • 下载安装文件

    image
    官网
    node_install_p_1

  • 安装Node

    双击它,默认是安装在C:\Program Files\nodejs下面

    打开C:\Program Files\nodejs目录你会发现里面自带了npm,直接用npm安装相环境既可进入node.js command prompt 命令窗口进入nodejs 安装目录 C:\Program Files\nodejs

    键入命令:cd C:\Program Files\nodejs 既可

  • 现在开始安装相关环境

    键入命令:npm install express 回车等待安装 express……..

    键入命令:npm install mysql 回车等待安装 mysql……..

    ……..安装什么组件,取决于环境搭建需求

    默认情况下上述组件都是安装在C:\Program Files\nodejs\node_modules文件夹下 这也是nodejs相关组件的自动查找路径

    这样在 Windows 下的 Node 就安装好了

Node for Linux

  • 下载 Node

    1
    $ wget http://nodejs.org/dist/v0.8.7/node-v0.8.7.tar.gz
  • 解压文件

    1
    $ tar -zxvf node-v0.8.7.tar.gz
  • 检查所需要配置

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    $ ./configure

    出现错误提示:
    Exception: Call to '(echo | $(echo ${CXX_host:-$(which g++)}) -m32 -E -

    > /dev/null 2>&1) && echo "-m32" || true' returned exit status 0. while

    loading dependencies of /opt/node-v0.8.7/node.gyp while trying to load

    /opt/node-v0.8.7/node.gyp
    • 如出现以上错误,安装gcc-c++
      1
      $ yum install gcc-c++
  • 进行安装(时间比较长):

    1
    $ make install
  • 检查是否成功安装,输入命令:

    1
    2
    $ node -v
    v5.5.0

    这样在 Linux 下的 Node 就安装好了

安装完 node 后 npm 也就安装完了


参考链接

Git 安装

Git 官网


Mac 安装 Git

Mac 本身就有 Git 了

1
2
3
4
$ which git
/usr/bin/git
$ git --version
git version 2.5.4 (Apple Git-61)

Mac 还没有安装 Git

使用homebrew来安装 Git - command line

安装 homebrew

  • 安装 homebrew,安装后

    1
    2
    3
    4
     $ which brew
    /usr/local/bin/brew
    $ brew --version
    Homebrew 0.9.5 (git revision e15a; last commit 2016-02-03)

然后就安装好了。。。

Git 官网的方式安装

git
官方文档的方式安装 - http://git-scm.com/


Windows 安装 Git

1. 来源于廖雪峰的Git教学网站

实话实说,Windows是最烂的开发平台,如果不是开发Windows游戏或者在IE里调试页面,一般不推荐用Windows。不过,既然已经上了微软的贼船,也是有办法安装Git的。
– 来源于廖雪峰的 Git 教学

Windows下要使用很多Linux/Unix的工具时,需要Cygwin这样的模拟环境,Git也一样。Cygwin的安装和配置都比较复杂,就不建议你折腾了。不过,有高人已经把模拟环境和Git都打包好了,名叫msysgit,只需要下载一个单独的exe安装程序,其他什么也不用装,绝对好用。

msysgit是Windows版的Git,从http://msysgit.github.io/下载,然后按默认选项安装即可。

安装完成后,在开始菜单里找到“Git”->“Git Bash”,蹦出一个类似命令行窗口的东西,就说明Git安装成功!
image
安装完成后,还需要最后一步设置,在命令行输入:

1
2
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"

因为Git是分布式版本控制系统,所以,每个机器都必须自报家门:你的名字和Email地址。你也许会担心,如果有人故意冒充别人怎么办?这个不必担心,首先我们相信大家都是善良无知的群众,其次,真的有冒充的也是有办法可查的。

注意git config命令的–global参数,用了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然也可以对某个仓库指定不同的用户名和Email地址。

2.官网的教学方法

image
下载链接

Git安装教程

Linux 安装 Git

  • 不同的版本有不同包管理工具
  • 我使用的是Centos

安装Git

1
$ sudo yum install -y git //然后输入你的 password

安装过程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.btte.net
* extras: mirrors.pubyun.com
* updates: mirrors.btte.net
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.7.1-3.el6_4.1 will be installed
--> Processing Dependency: perl-Git = 1.7.1-3.el6_4.1 for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: rsync for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Error) for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: openssh-clients for package: git-1.7.1-3.el6_4.1.x86_64
--> Running transaction check
---> Package openssh-clients.x86_64 0:5.3p1-112.el6_7 will be installed
--> Processing Dependency: openssh = 5.3p1-112.el6_7 for package: openssh-clients-5.3p1-112.el6_7.x86_64
--> Processing Dependency: libedit.so.0()(64bit) for package: openssh-clients-5.3p1-112.el6_7.x86_64
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.noarch 0:1.7.1-3.el6_4.1 will be installed
---> Package rsync.x86_64 0:3.0.6-12.el6 will be installed
--> Running transaction check
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
---> Package openssh.x86_64 0:5.3p1-94.el6 will be updated
--> Processing Dependency: openssh = 5.3p1-94.el6 for package: openssh-server-5.3p1-94.el6.x86_64
---> Package openssh.x86_64 0:5.3p1-112.el6_7 will be an update
--> Running transaction check
---> Package openssh-server.x86_64 0:5.3p1-94.el6 will be updated
---> Package openssh-server.x86_64 0:5.3p1-112.el6_7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
git x86_64 1.7.1-3.el6_4.1 base 4.6 M
Installing for dependencies:
libedit x86_64 2.11-4.20080712cvs.1.el6 base 74 k
openssh-clients x86_64 5.3p1-112.el6_7 updates 438 k
perl-Error noarch 1:0.17015-4.el6 base 29 k
perl-Git noarch 1.7.1-3.el6_4.1 base 28 k
rsync x86_64 3.0.6-12.el6 base 335 k
Updating for dependencies:
openssh x86_64 5.3p1-112.el6_7 updates 274 k
openssh-server x86_64 5.3p1-112.el6_7 updates 324 k

Transaction Summary
================================================================================
Install 6 Package(s)
Upgrade 2 Package(s)

Total download size: 6.1 M
Downloading Packages:
--------------------------------------------------------------------------------
Total 1.8 MB/s | 6.1 MB 00:03
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction

Updating : openssh-5.3p1-112.el6_7.x86_64 1/10

Installing : 1:perl-Error-0.17015-4.el6.noarch 2/10

Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64 3/10

Installing : openssh-clients-5.3p1-112.el6_7.x86_64 4/10

Installing : rsync-3.0.6-12.el6.x86_64 5/10

Installing : perl-Git-1.7.1-3.el6_4.1.noarch 6/10

Installing : git-1.7.1-3.el6_4.1.x86_64 7/10

Updating : openssh-server-5.3p1-112.el6_7.x86_64 8/10

Cleanup : openssh-server-5.3p1-94.el6.x86_64 9/10

Cleanup : openssh-5.3p1-94.el6.x86_64 10/10

Verifying : openssh-clients-5.3p1-112.el6_7.x86_64 1/10

Verifying : perl-Git-1.7.1-3.el6_4.1.noarch 2/10

Verifying : 1:perl-Error-0.17015-4.el6.noarch 3/10

Verifying : rsync-3.0.6-12.el6.x86_64 4/10

Verifying : libedit-2.11-4.20080712cvs.1.el6.x86_64 5/10

Verifying : openssh-5.3p1-112.el6_7.x86_64 6/10

Verifying : git-1.7.1-3.el6_4.1.x86_64 7/10

Verifying : openssh-server-5.3p1-112.el6_7.x86_64 8/10

Verifying : openssh-5.3p1-94.el6.x86_64 9/10

Verifying : openssh-server-5.3p1-94.el6.x86_64 10/10

Installed:
git.x86_64 0:1.7.1-3.el6_4.1

Dependency Installed:
libedit.x86_64 0:2.11-4.20080712cvs.1.el6
openssh-clients.x86_64 0:5.3p1-112.el6_7
perl-Error.noarch 1:0.17015-4.el6
perl-Git.noarch 0:1.7.1-3.el6_4.1
rsync.x86_64 0:3.0.6-12.el6

Dependency Updated:
openssh.x86_64 0:5.3p1-112.el6_7 openssh-server.x86_64 0:5.3p1-112.el6_7

Complete!

安装完成后

1
2
3
4
$ which git
/usr/bin/git
$ git --version
git version 1.7.1

OK, 其他版本的Linux大概也就是这样的了

参考链接