git是一个非常强大的开源的版本控制工具
- 安装
sudo apt-get install git
- 配置与使用
指定用户名与邮箱
git config --global user.name "Your name"
git config --global user.email "YourEmail.domain.com"
查看配置信息
git config --list
创建一个本地repository
git init my_repo
切换到my_repo,添加文件hello.cpp
vim hello.cpp
将这个文件通过git添加到刚刚创建的my_repo
git add hello.cpp
将my_repo的变化更新情况提交
git commit -m "something changed"
同步到个人github账户
先在github创建一个新的repository(e.g. my_repo),并拷贝其URL
将本地的repo提交到github
git remote add origin https://github.com/author/my_repo.git
git push origin master
然后会提示让输入用户名密码,输入完回车就行了。
在之后要向这个repo提交代码,比如新增了一个test文件
只需要
git add test
git commit -m "XXXXX"
最好先同步github到本地
git pull origin master
然后
git push origin master
就行了。
这些是最基本的入门知识,还有很多其他更丰富的用法需要后面继续学习。