github的使用:


1.注册github账号

     进入官网: https://github.com/

     sign up设置用户名,邮箱,密码进行注册

2.安装git

   terminal中运行  sudo apt-get install git即可

3.linux下产生的一个ssh公钥放到github上

    ssh-keygen -t rsa -C"mail@mail.com"

    敲三册回车(默认),将产生一个公钥于  ~/.ssh/ld_rsa.pub中

   cat~/.ssh/ld_rsa.pub

   复制其中的内容粘贴到SSH keys>>Add SSH key下面的key中,上面的Title随便写

    ssh –Tgit@github.com

   验证是否连接成功,显示以下这句即连接成功

    hi xxx. You've successfully authenticated, but GitHub does not provide shell access.

4.新建并提交项目

   mkdir testdir & cd testdir  

  touch README.md 

  git init       //初始化一个本地库  

  git add 你的文件(夹)名称      //添加文件到本地仓库

  git commit -m "first commit"    //提交到本地库并备注,此时变更仍在本地。 

  git commit -a   //自动更新变化的文件,a  auto  

  git remote add xxx git@github.com:xxx/xxx.git    //增加一个远程服务器的别名。 

  git push -u xxx master    //将本地文件提交到Github,更新本地变更到github服务上。


5.命令

 git log 

git branch 查看当前所在分支


常用git命令    http://www.cnblogs.com/sunada2005/archive/2013/06/06/3121098.html

git help                                 #可查看git的常用命令
git config --global user.name "Your Name Here"           #设置commit的署名
git config --global user.email "your_email@example.com"      #设置commit的email
git config [--local|--global|--system] --list/-l          #查看本地的global信息
git config [--local|--global|--system] --unset[-all] user.name  #删除user.name信息。如果user.name对应多个值,可用unset-all来删除
git remote add XXX https://github.com/username/repo_name.git    #设置github的连接
git clone git://github.com/your_account/aimed_repo.git       #复制一个repo到本地 
git remote -v                               #查看本地设置的url连接信息 
git status                                 #查看当前工作的
branch git branch                             #查看本地所有的
branch git branch -a                           #查看远程的所有分支 
git branch -d branch_name                          #删除本地branch_name这一分支 
git push origin --delete branch_name                   #删除名为branch_name的远程分支 
git checkout branch_name                         #切换到名为branch_name的分支上 
git chechout -b branch_name                        #在本地新建一个名为branch_nam的分支 
git diff test_branch_name                         #查看当前branch与test_branch_name中代码的区别 
git mv filename newfilename                      #文件重命名 
git push XXX branch_name                        #上传指定的branch到远端 
git pull                                  #将远程上的版本与本地版本进行合并,相当于get fetch + git merge 
git reset --hard                             #将刚才进行的git pull所进行的操作取消,恢复本地版本合并前的原貌

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐