zoukankan      html  css  js  c++  java
  • 学习使用GitHub(一)--之入门

    因为经常Windows和linux系统交替的使用,在实验室一台电脑,在家一台电脑,自己的电脑和实验室的电脑上面的代码往往没法同步,以前由于种种原因(其实就是懒,没有学习GitHub这样的代码管理工具),临近找工作,又是要做个项目,在实验室偷偷的做,回到家里需要提前将实验室的代码拷到U盘中,太麻烦,看到哥们用GitHub特别方便,自己也学习下,并做记录如下:

    1.首先注册个GitHub的帐号,登陆GitHub官网就好,注册过程跟其他的网站一样

    2.注册完成之后,GitHub会有很人性化的指导,告诉你第一次创建版本库该怎么做,在linux下,有相应的代码

    3.git 如果没有安装,输入git 命令会有提示安装的命令提示sudo apt-get install git

    4.然后找个代码同步的目录,git init, 这样就将该目录默认为与github同步的目录

    5.添加要同步的文件,git add 'README.md'

    6.git commit -m 'commit readme', -m 后面的字符串是提交成功后提示的内容,当然也会记录到github上面,所以最好是有意义的字符串

    这样一个简单的Git仓库就建立好了,基本的上传代码也有了.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    接下来,如果本地的文件修改了,但是没有跟Git仓库进行同步怎么办?

    1.用git status查看当前仓库状态,如果修改了README.md文件,会有以下提示:

    On branch master
    Your branch is up-to-date with 'origin/master'.
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
    	modified:   README.md
    
    no changes added to commit (use "git add" and/or "git commit -a")
    

     即提示有文件是改动的,并且会有提示该如何提交到Git仓库中

    2.跟新建一个仓库提交文件一样,git add README.md, git commit -m 'distribution updated',这样就完成了对本地修改后文件的提交

    [master 24d8c26] modify the readme, that add the discripiton of the competion
    Your name and email address were configured automatically based
    on your username and hostname. Please check that they are accurate.
    You can suppress this message by setting them explicitly:
    
        git config --global user.name "Your Name"
        git config --global user.email you@example.com
    
    After doing this, you may fix the identity used for this commit with:
    
        git commit --amend --reset-author
    
     1 file changed, 2 insertions(+), 1 deletion(-)
    

     3.提交之后再输入git status

    On branch master
    Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)
    
    nothing to commit, working directory clean
    

     即显示没有修改的文件,即nothing to commit

  • 相关阅读:
    newCachedThreadPool无上限线程池使用
    newFixedThreadPool固定线程使用
    java定时器
    http文件上传/下载
    ThreadPoolExecutor线程池
    阻塞队列
    非阻塞队列
    IO文件夹拷贝(文件内含有文件和文件夹)
    MD5加密
    web.xml文件的作用
  • 原文地址:https://www.cnblogs.com/xiamaogeng/p/4435354.html
Copyright © 2011-2022 走看看