您的位置:首页 > 编程语言

git工具使用

2016-01-31 15:50 417 查看
1.从github克隆代码,在本地使用:

git clone http://github.com/Weltch/helloworld.git



2.拉取github代码到本地修改,并提交(第一次建立git仓库);

a)  新建空目录tmp;

b) cd tmp;

c) 建立git仓库,git init;

d) 拉取远程代码: git pull http://github.com/Weltch/helloworld.git



e) 添加文件:git  add 文件名或文件名

f) 确认提交: git  commit  -m “注释说明”

g) 向github添加分支:git remote add origin http://github.com/Weltch/helloworld.git



(提示:如果报错fatal: remote origin already exists,则先删掉origin分支,再提交。删除分支:git remote rm origin)

h) 提交分支到远程仓库:git push -u origin master

 

3. 更新代码(已经建立git仓库);

a)首先确定git仓库是否最新,拉取一遍:git pull即可;



b) 添加修改过的文件: git add 文件

c) 确认提交:git commit -m “add 文件”

d) 直接提交到远程仓库:git push -u origin master

 

4. 添加新分支到远程仓库

a) 在本地创建并切换到新分支:git checkout -b newbranch;

b) 将修改后的文件添加到该分支,git add *; git commit -m “*”;

c) 查看远程有没有newbranch分支:git branch -r;

d) 如果没有则提交到远程git仓库:git push origin newbranch;这时在远程就会生成newbranch的分支;

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  软件工程 git github