赞
踩
快速使用gitoschina入门
1、首先在oschina注册个用户 https://git.oschina.net/,然后在左下角项目,点击加号新建项目。
2、在Ubuntu上面安装git
3、设置邮箱,用户名
4、创建一个目录作为仓库,仓库名字为git_client
5、初始化仓库git init
6、创建一个Test程序文件 touch 1.c
7、添加程序到仓库 git add 1.c
8、向仓库提交程序 git commit -m “”first commit“”
9、添加远端仓库 git remote add origin git@git.oschina.net:xxxxxxx/xxx.git (你申请的http地址或者sshdiz)
10、注意要是直接 git push -u origin master 输入用户名,和密码后会报错误的,因为本地没有远程仓库的参数,下图错误
可以先执行git pull --rebase origin master,然后输入用户名,密码。
获取远端仓库信息成功!
11、向远端仓库提交 git push -u origin master
提交成功!
如果已有项目,cd 到项目目录,执行git remote add origin git@git.oschina.net:xxxxxxx/xxx.git
git push -u origin master。
12、查看gitoschina服务器上项目里提交的文件
关于git简单的操作命令
1
2
3
4
5
6
|
touch README.md //新建说明文件
git init //在当前项目目录中生成本地git管理,并建立一个隐藏.git目录
git add . //添加当前目录中的所有文件到索引
git commit -m "first commit" //提交到本地源码库,并附加提交注释
git remote add origin https://github.com/chape/test.git //添加到远程项目,别名为origin
git push -u origin master //把本地源码库push到github 别名为origin的远程项目中,确认提交
|
更新代码
1
2
3
4
|
cd /d/fddcn
git <span id="3_nwp"><a id="3_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fcaibaojian%2Ecom%2Fgit%2Dcreate%2Dproject%2D2%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=66009120_cpr&k=add&k0=master&kdi0=8&k1=%D4%B4%C2%EB&kdi1=8&k2=add&kdi2=8&k3=%B9%A4%BE%DF&kdi3=8&k4=status&kdi4=8&sid=8493c5cbd70f5e64&ch=0&tu=u1896884&jk=9a30250b75dc4a4b&cf=29&fv=16&stid=9&urlid=0&luki=3&seller_id=1&di=128" target="_blank">add</a></span> .
git commit -m "update test" //检测文件改动并附加提交注释
git push -u origin master //提交修改到项目主线
|
github常用命令
1
2
3
4
5
6
7
8
9
|
git push origin <span id="0_nwp"><a id="0_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fcaibaojian%2Ecom%2Fgit%2Dcreate%2Dproject%2D2%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=66009120_cpr&k=master&k0=master&kdi0=8&k1=%D4%B4%C2%EB&kdi1=8&k2=add&kdi2=8&k3=%B9%A4%BE%DF&kdi3=8&k4=status&kdi4=8&sid=8493c5cbd70f5e64&ch=0&tu=u1896884&jk=9a30250b75dc4a4b&cf=29&fv=16&stid=9&urlid=0&luki=1&seller_id=1&di=128" target="_blank">master</a></span> //把本地<span id="1_nwp"><a id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fcaibaojian%2Ecom%2Fgit%2Dcreate%2Dproject%2D2%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=66009120_cpr&k=%D4%B4%C2%EB&k0=master&kdi0=8&k1=%D4%B4%C2%EB&kdi1=8&k2=add&kdi2=8&k3=%B9%A4%BE%DF&kdi3=8&k4=status&kdi4=8&sid=8493c5cbd70f5e64&ch=0&tu=u1896884&jk=9a30250b75dc4a4b&cf=29&fv=16&stid=9&urlid=0&luki=2&seller_id=1&di=128" target="_blank">源码</a></span>库push到Github上
git pull origin master //从Github上pull到本地源码库
git config --list //查看配置信息
git <span id="2_nwp"><a id="2_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?rs=1&u=http%3A%2F%2Fcaibaojian%2Ecom%2Fgit%2Dcreate%2Dproject%2D2%2Ehtml&p=baidu&c=news&n=10&t=tpclicked3_hc&q=66009120_cpr&k=status&k0=master&kdi0=8&k1=%D4%B4%C2%EB&kdi1=8&k2=add&kdi2=8&k3=%B9%A4%BE%DF&kdi3=8&k4=status&kdi4=8&sid=8493c5cbd70f5e64&ch=0&tu=u1896884&jk=9a30250b75dc4a4b&cf=29&fv=16&stid=9&urlid=0&luki=5&seller_id=1&di=128" target="_blank">status</a></span> //查看项目状态信息
git branch //查看项目分支
git checkout -b host//添加一个名为host的分支
git checkout master //切换到主干
git merge host //合并分支host到主干
git branch -d host //删除分支host
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。