使用git

基本操作

1.基本参数设置

安装完git后,主要参数还有两个。

git config --global user.name "duandoke"
git config --global user.email wangdongddk@163.com

2.把指定目录设置为repository(仓库)

git init

3.新增文件

echo abc>1.txt
git add 1.txt 或者 git add .
git commit -m "add 1.txt"

4.本地repository传到服务器

git remote add origin https://git.oschina.net/duandaoke/os.git要求服务已经建立同名仓库
git push origin master origin是名字 master是分支

5.把远程的仓库clone到本地

git clone http://git.oschina.net/duandaoke/os.git

练习

1.在A电脑新建工程

mkdir temp
cd temp
echo a>1.txt
echo b>2.txt
git init

git config --global user.name duandaoke
git config --global user.email wangdongddk@163.com

2.把修改后的工程上传到服务器

git add .
git commit -m '1.txt 2.txt'
git remote add org https://git.oschina.net/duandaoke/temp.git
git push org master

3.在B电脑中下载工程

git clone https://git.oschina.net/duandaoke/temp.git
cd temp/

4.在B电脑中修改工程并上传

git rm 2.txt
echo c>3.txt
git add .
git commit -m 'b remove_2.txt and create 3.txt'
git push

5.在A中更新修改后的工程

git pull

posted on 2014-07-22 15:41  短刀客  阅读(98)  评论(0)    收藏  举报

导航