今天折腾了github,中间碰到些问题,查了很多资料,但是其中对于某些细节描述的不是很清晰,这里记下来免的后来者再费劲。
我的环境:
ubantu11.10
1.下载git包
sudo aptitude install git
//若是你不想用aptitude的话,可以用下面命令
sudo apt-get install git
//我这里用aptitude是因为这个命令安装和卸载比单纯的apt-get干净。
2.查看是否正确安装
git --help
inter12@inter12-VirtualBox:~/mwork/manlost$ git --help
usage: git [--version] [--exec-path[=<path>]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=<path>] [--work-tree=<path>]
[-c name=value] [--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
看到如下信息就代表已经安装成功了!
3.到github注册一个帐号,并新建一个Repositories。地址为:http://github.com
我这里暂定为:test 。至于具体如何注册可见下面链接中描述。
http://www.36ria.com/4742
4.建立porject
Global setup:
4.1 Set up git
git config --global user.name "gittest" // 设置在git用户名
git config --global user.email gityesy@gmail.com // 设置在git的邮箱 这两个在注册的时候填写即可
4.2 生成pubkey
ssh-keygen -t rsa -C "gittest@gmail.com" // 这个邮箱可以是任意邮箱,只是作为注释使用,建议还是github的注册邮箱
若是不需要密码的话,一直按回车即可。
这个时候会生成一个id_rsa.pub,将这个文件中的内容添加到github中的SSH KEY中。
4.3:建工程
mkdir gittest cd gittest git init // 初始化仓库 touch README git add README git commit -m 'first commit' git remote add origin git@github.com:manlost/manlost.git git push -u origin master // 拉出主干分支
若是在最后一步报一下错误的话
Agent admitted failure to sign using the key. Permission denied (publickey).
执行 ssh-add 将专用密钥添加到 ssh-agent 的高速缓存中
5.收工这样就建立了本地同github之间的联系。
若是对于上面安装还存在疑问,可参见链接:http://help.github.com/mac-set-up-git/
一个描述较为详细文档
http://www.linuxgem.org/user_files/linuxgem/Image/git-tutor.pdf
本文档详细介绍了如何在Ubuntu 11.10环境下安装Git并配置GitHub账号的过程,包括Git的基本命令、SSH密钥生成及上传、GitHub项目的创建与同步等关键步骤。
688

被折叠的 条评论
为什么被折叠?



