GitHub 使用(Win7 下Git Bash)

来源:互联网 发布:bl国产网络剧 编辑:程序博客网 时间:2024/06/08 06:15

1、建立工程


     1、进入工程路径

           1、启动git bash, 输入cd 工程项目路径 进入对应路径

     2、在工程目录处单击右键——“Git Bash here”

   2、建立存储信息和跟踪改动的文件夹.git

     git init

    注释:查看.get 目录内容

$ ls -altr .git

total 40

drwxrwxr-x 4 git git 4096 Aug 13 22:39 refs

drwxrwxr-x 4 git git 4096 Aug 13 22:39 objects

drwxrwxr-x 2 git git 4096 Aug 13 22:39 info

drwxrwxr-x 2 git git 4096 Aug 13 22:39 hooks

-rw-rw-r -- 1 git git 23 Aug 13 22:39 HEAD

-rw-rw-r -- 1 git git 73 Aug 13 22:39 description

-rw-rw-r -- 1 git git 92 Aug 13 22:39 config

drwxrwxr-x 2 git git 4096 Aug 13 22:39 branches

drwxrwxr-x 36 git git 4096 Aug 13 22:39 ..

drwxrwxr-x 7 git git 4096 Aug 13 22:39 .


若提示错误信息:

 Warning: Your console font probably doesn‘t support Unicode. If you experience trange characters in the output, consider switching to a TrueType font such as ucida Console!

这是代码中含有中文导致的,且把代码改为utf-8也是解决不了的,解决方式:

执行以下命令:

git config [--global] core.quotepath off

git config [--global] --unset i18n.logoutputencoding

git config [--global] --unset i18n.commitencoding


2、操作步骤

   1、向工程添加和提交文件(文件需与.get文件夹同路径)

    $ git add *.cs
    $ git commit -m ‘Initial upload of the project’
    注释:
    1、如果之前没有使用 git config 指定用户名和电子邮件地址,这里会报错
    $ git commit -m ‘Initial upload of the project'
    *** Please tell me who you are.
    2、使用git commit 进行版本控制,将索引内容添加到仓库。详细信息见:git commit简介

2、删除向工程添加的文件

       1、 git rm --cached "文件路径",不删除物理文件,仅将该文件从缓存中删除;

       2、 git rm --f "文件路径",不仅将该文件从缓存中删除,还会将物理文件删除(不会回收到垃圾桶)。

3、使用编辑器更改本地文件

    $ vi Class1.cs
    注释:退出vi编辑器:按Esc到命令格式,然后按住Shift输入两个大写Z。vi编辑器操作

4、查看当前文件与git仓库中的文件变动

    $ git diff

5、将文件变动保存到git仓库

    1、将文件添加到了临时区域(staging area)
      $ git add Class1.cs
    2、提交
      $ git commit
      注释:使用git commit时会弹出系统默认编辑器,写入改动注释,保存并退出后即自动提交。

6、查询本地变动文件是否提交

    $ git status

  1、如果本地的文件相较远端git仓库上没有任何改动,提示信息:

    # On branch master
     nothing to commit (working directory clean)

  2、如果本地做了改动但是没有提交,提示信息:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage

        modified:   Class1.cs

7、查看文件历史和以往的注释

    $ git log Class1.cs

8、window下配置SSH连接GitHub、GitHub配置ssh key

   ssh-keygen –C “你的email地址 “ –t rsa

          注释关于SSH

3、发布工程

          提交代码到github托管 

           1、连接github仓库

    git remote add origin https://github.com/whu-zhangmin/whuzm.git

2、上传文件

git push origin master 

         由于SSH配置文件的不匹配,导致的Permission denied (publickey)及其解决方法

0 0
原创粉丝点击