现在的位置: 首页 > 综合 > 正文

git学习一 基于linux ubuntu git安装与配置

2014年01月28日 ⁄ 综合 ⁄ 共 1831字 ⁄ 字号 评论关闭

1.安装git

># sudo apt-get build-dep git-core git-doc

这个会安装git-core和git-doc依赖的库。

接下来去官网下载git的源码包。把下载的git包解压。

在解压的目录下执行下列的命令来编译git

>#make prefix=/usr/local all doc

然后需要安装git

>#sudo make install install install-doc

这样你的git就可以被该计算机上的所有用户使用了。

你可以使用下面的命令来查看自己的git版本号。

>#git --version

2.配置git

由于git并不像svn那样有中心仓库,所以并不需要想中心仓库提供用户名和密码等。但是我们还是需要告诉

要通过用户名和email地址来给git传递一些信息。这些信息通常被设置为global。这里必须设置的两个是user.name

和user.email。user.name是提交代码时显示的名称,user.email可以被其他开发者用于联系你使用。

>#git config --global user.name "your name"

>#git config --global user.email "youraddr@xxx.com"

然后我们可以通过下面的命令来查看是否修改成功了呢。

>#git config --global --list

我们应该会看到我们刚才配置的信息。

除此之外,还可以调整git的显示颜色来区分不同的变化。

>#git config --global color.ui "auto"

3.查看git帮助

>#git help

命令可以查看git的命令

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

如果想查看git的具体命令使用可以通过下面命令做到,例如查看clone命令。

>#git help clone

到这我们已经配置好我们的git了,接下来就可以创建我们的工程了。明天接着写哟。

抱歉!评论已关闭.