Android Studio
一、工作区、暂存区、版本库
工作区:即为代码编辑区,修改之后,可用git status
查看修改后状态
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
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: app/src/main/java/com/carpediem/vv/funny/Fragment/GameFragment.java
no changes added to commit (use "git add" and/or "git commit -a")
暂存区:暂存区属于版本库的一部分,当修改后可用git add <file>
添加到暂存区此时查看git status
android studio Add选项
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: app/src/main/java/com/carpediem/vv/funny/Fragment/GameFragment.java
版本库:修改已经添加到暂存区,使用git commit -m "注释"
即可提交到版本库中
Android studio Commit选项
二、回退栈
当修改代码后,需要撤销,不想一步一步Ctrl+Z
,即一步还原在工作区所做的事情。使用git checkout -- <file>
即可。
android studio Revert选项
三、分支
查看分支:git branch
创建分支:git branch
切换分支:git checkout
创建+切换分支:git checkout -b
合并某分支到当前分支:git merge
删除分支:git branch -d