git
来源:互联网 发布:软件杯比赛规则 编辑:程序博客网 时间:2024/05/04 01:39
项目一直使用git来管理代码,也用过svn,但是还是git用起来比较舒服。
clone 代码
git clone url
切换分支(直接同步远程分支,创建新的本地分支)
git fetch
git checkout [local branch]
切换分支(本地创建新的分支)
git checkout -b origin/[remote branch]
查看分支(本地以及远程)
git branch -a
删除本地分支
git branch -D [local branch]
创建远程分支(已某一本地分支创建一个新的远程分支)
git push origin [local branch]:[remote branch]
删除远程分支
git push origin :[remote branch]
merge代码到当前分支
git merge origin/[remote branch]
拉代码
git pull
提交代码
git add [file] 或者 git add . 或者git add --all
git commit -m "description'
git push origin [local branch]:[remote branch]
回退add 的改动
git reset HEAD [file] 或者 git reset HEAD .
回退commit(一条记录)
git reset HEAD~1
submodule:为主项目引用关联项目
例子:主项目cartoon,关联项目commonm
本地创建远程仓库
git init
git add --all
git commit -m "first commit"
git remote add origin https://github.com/whuthm/cartoon.git
git push -u origin master
在cartoon项目中关联common
创建submodule
git submodule add https://github.com/whuthm/common.git common
目录如下
里面有一个.gitmodules文件以及common工程目录
而git status查看后只有两个改动,common里面的文件没有改动
提交此改动
.gitmodules文件的内容如下
如此就完成了关联到另一个工程。
在服务器上使用ant编译示例如下
git submodule init
git submodule update
cd common
git remote update
git checkout remotes/origin/master
cd ../Cartoon
/usr/local/apache-ant-1.9.3/bin/ant .release
- git
- git
- Git
- Git
- Git
- Git
- git
- git
- Git
- GIT
- git
- GIT
- Git
- git
- git
- Git
- GIt
- git
- Solr配置中文分词器mmseg4j详解
- A+B和C (15)
- poj 3071 Football DP
- Q9.1 Ruan upp a staircase
- openGL从零学起之入门介绍
- git
- FAST_START_MTTR_TARGET
- 决策树ID3算法
- Flatten Binary Tree to Linked List Leetcode Python
- 交易偏见--《别做正常的傻瓜》摘记2
- 关于syslogd与klogd
- C++ 语言知识汇集
- Binary Tree Level Order Traversal
- CodeForces - 348A