创建GitHub 经验之谈

2011-09-16 10:57:17 by 【6yang】, 208 visits, 收藏 | 返回

我的案例:https://github.com/ydzhony1/Jlib

一.    安装配置
    安装git(Git-1.7.6-preview20110708.exe)  (参照: http://help.github.com/win-set-up-git/)
    创建dsa密钥或rsa密钥(github目前使用dsa).
    cd ~/.ssh (所指当前.ssh目录 一般在c:user用户下)
    $ ssh-keygen -t rsa -C "your_email@youremail.com"
    回车,输入两次密码;
    创建好后,可以ls
    即可看到对应的密钥文件id_dsa.pub(密钥) 和 id_dsa
    Next step: vim id_dsa.pub (复制密钥 全选ctrl+insert(复制),当然教你一个快捷键(shift+insert是粘贴));
    Next step: $ ssh -T git@github.com(远程访问是否OK, 如果提示hello, 'xxxxxxx'字样,恭喜你通过了);
    Then: Set Up Your Info
    $ git config --global user.name "Firstname Lastname"
    $ git config --global user.email "your_email@youremail.com"

    服务器配置初始化:git init -bare 而不能直用git init 因为此时需要创建一个空的仓库;
二. 下载服务端代码
    git init
    git pull git@github.com:ydzhony1/Jlib.git
    或:
   git clone git@github.com:ydzhony1/Jlib.git (下载)
    下载到你指定的路径.
   
   
三. 上传客服端代码
   
    git add .   
    git commit -m "submit current coding"
    git push origin master (上传)
    输入你的密钥回车.

 

四. 删除远程分支

    git push origin poject --delete
    git branch -a(查看远程所有分支)

五. 出现无法push的时候解决办法

    可以先分将分支备,再删除,再clone,重新再git push ogigin master 即可。

六. 还原当前记录
git reset HEAD~0 --hard

git checkout master -f

git checkout file

七. 常见问题

1.当使用git push origin master
出现本地还原更新,导致与远程的版本不一致时,或
提示:
![rejected]        master -> master (non-fast-forward)

error: failed to push some fefs to .....信息

解决方法:
git push origin master -f
(-f指强制更新到最新本地的版本)

2.提交命令

git commit –a –m “hello this is my commit”

与git add . 和 git commit -m "hello this is my commit";是一样的,有一个区别是:直接在commit中附加信息,更加方便。但是不可以在文件或者文件夹数目发生变化的情况下提交,必须用git add。

八. unix常用命令

tar cf Jlib.tar .(压缩文件)
tar xf Jlib.tar(解压文件)

我的案例:https://github.com/ydzhony1/Jlib

 

分享到:
share

    图片原图

    loading

    loading