ubuntu下使用git, github

来源:互联网 发布:吉他推荐 知乎 编辑:程序博客网 时间:2024/05/21 10:57

1、git安装

ubuntu下安装git非常简单,直接使用apt-get命令即可。

sudo apt-get install git

2、查看git安装是否成功

安装完成后在终端中可以输入git命令来查看git是否安装成功。

git

或者使用

git --version

来查看git的安装版本。

3、配置git

在终端中依次输入下述命令,引号里面的内容替换成你的用户信息。

git config --global user.name "robin"git config --global user.email "chou_robin@hotmail.com"git config --listssh-keygen -C 'you email address@gmail.com' -t rsa

4、在github端添加密钥

上述命令执行完成之后就会在ubuntu系统中产生一个SSH的密钥。进入到home目录下,打开id_rsa.pub文件,将此文件中的内容拷贝到github的配置项中。这一步十分关键

5、克隆项目

从github上clone一个项目到本地:

git clone git@github.com:bzhou830/DataStruct.gitCloning into 'DataStruct'...Warning: Permanently added the RSA host key for IP address '192.30.252.122' to the list of known hosts.remote: Counting objects: 61, done.remote: Total 61 (delta 0), reused 0 (delta 0), pack-reused 61Receiving objects: 100% (61/61), 19.67 KiB | 0 bytes/s, done.Resolving deltas: 100% (8/8), done.Checking connectivity... done.

6、源码修改后查看git状态

修改源码后,查看修改状态

git status On branch masterYour 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:   String.cpp    modified:   main.cppUntracked files:  (use "git add <file>..." to include in what will be committed)    Makefile    strno changes added to commit (use "git add" and/or "git commit -a")

7、添加新文件到仓库

添加修改

git add Makefilegit add strgit commit -m "add"

8、推送源码到github源码仓库

推送源码到github源码仓库:

git push origin masterCounting objects: 7, done.Compressing objects: 100% (5/5), done.Writing objects: 100% (5/5), 13.38 KiB | 0 bytes/s, done.Total 5 (delta 1), reused 0 (delta 0)To git@github.com:bzhou830/DataStruct.git   8a89341..1cc6526  master -> master
0 0
原创粉丝点击