Git总结1

来源:互联网 发布:帝国cms阿里云oss插件 编辑:程序博客网 时间:2024/06/02 19:32

获取远程库到本地库

xiongmc@xiongmc-desktop:~/project$ git clone git@172.21.20.95:Home

Cloning into 'Home'...
remote: Counting objects: 88, done.
remote: Compressing objects: 100% (77/77), done.
remote: Total 88 (delta 30), reused 0 (delta 0)
Receiving objects: 100% (88/88), 211.13 KiB, done.

Resolving deltas: 100% (30/30), done.

进入项目主目录

xiongmc@xiongmc-desktop:~/project$ cd Home/
xiongmc@xiongmc-desktop:~/project/Home$ git branch

* master

创建开发分支

xiongmc@xiongmc-desktop:~/project/Home$ git branch htt_app_home_20130726

切换到开发分支

xiongmc@xiongmc-desktop:~/project/Home$ git checkout htt_app_home_20130726 

Switched to branch 'htt_app_home_20130726'

查看当前分支

xiongmc@xiongmc-desktop:~/project/Home$ git branch
* htt_app_home_20130726

  master


xiongmc@xiongmc-desktop:~/project/Home$ git status
# On branch htt_app_home_20130726
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# .project
# bin/
nothing added to commit but untracked files present (use "git add" to track)

#更新项目以便适合于当前环境 ,进入开发阶段。

xiongmc@xiongmc-desktop:~/project/Home$ android update project -p . -t android-17
Updated and renamed default.properties to project.properties
Updated local.properties
No project name specified, using project folder name 'Home'.
If you wish to change it, edit the first line of build.xml.
Added file ./build.xml

Added file ./proguard-project.txt

xiongmc@xiongmc-desktop:~/project/Home$ git status
# On branch htt_app_home_20130726
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# .project
# bin/
# build.xml
# local.properties
# proguard-project.txt
# project.properties

nothing added to commit but untracked files present (use "git add" to track)

查看当前状态

xiongmc@xiongmc-desktop:~/project/Home$ git status
# On branch htt_app_home_20130726
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified:   res/layout-land/home.xml
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# .project
# bin/
# build.xml
# gen/
# local.properties
# proguard-project.txt
# project.properties

no changes added to commit (use "git add" and/or "git commit -a")

提交开发分支到本地库。这里使用 qgit 做到。

xiongmc@xiongmc-desktop:~/project/Home$ qgit
xiongmc@xiongmc-desktop:~/project/Home$ gitk

xiongmc@xiongmc-desktop:~/project/Home$ git status
# On branch htt_app_home_20130726
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
# .project
# bin/
# build.xml
# gen/
# local.properties
# proguard-project.txt

# project.properties

提交本地库到远程库,以便管理代码,共其他开发人员使用(或发布最终用户)

xiongmc@xiongmc-desktop:~/project/Home$ git push origin hht_app_home_20130726:master 


1) 先把git的东西fetch到你本地然后merge后再push

$ git fetch

$ git merge

这2句命令等价于

$ git pull  




原创粉丝点击