• ubuntu git 简单入门【转】


    转自:http://blog.chinaunix.net/uid-20718384-id-3334859.html

    1. 安装

    1. sudo apt-get install git-core

    2.  初始化git仓库(一个已有的项目)如hello

    1. cd hello
    2. git init
    3. git add *
    4. git commit -a -m "hello project"


    3. git本地clone仓库

    1. git clone /path/to/hello

    4. git 远程clone(使用ssh)

    1. git clone user@server:/path/to/hello

    5.  修改数据并提交

    1. vi hello.c #modify the file
    2. git commit -m "add comment" #本地提交
    3. git push orgin master #提交到服务器
    4. git pull origin master #从服务器同步代码到本地

    6. git 常用命令

    1. git rm #删除文件
    2. git checkout master #检出master代码
    3. git checkout -b testing master #新建分支
    4. git merge #合并分支
    5. git help #查看git 常用命令

    7. git failed to push 问题
    参考:http://blog.sunzy.org/?p=341

    解决办法:
    一,在服务器上初始化仓库的时候用git –bare init;

    用”git init”初始化的版本库(暂且称之为working repository) 将会生成2类文件:“.git“版本库目录(记录版本历史)和实际项目文件的拷贝。你可以把这类版本库叫做“工作目录”。工作目录是一个包含有版本历史目 录“.git”和源文件的目录。你可以在工作目录修改你的源文件并使用”git add”和”git commit”命令进行版本管理。

    用“git init –bare”初始化的版本库(暂且称之为bare repository)仅包含”.git”目录(记录版本历史),不含项目源文件拷贝。如果你进入版本目录,你会发现仅有”.git”目录,没有其他文件。版本库仅包含记录着版本历史的文件。

    二,如果用的是git init的话,就要修改下服务器上的配置(.git/config),添加:
    [receive]
    denyCurrentBranch = ignor

  • 相关阅读:
    ARC 080
    CodeForces
    [Lydsy1806月赛] 路径统计
    AGC 022 C
    AGC 022 B
    AGC 020 B
    UVA
    AGC 018 A
    python
    python
  • 原文地址:https://www.cnblogs.com/sky-heaven/p/5179757.html
Copyright © 2020-2023  润新知