项目管理
1、从github获取项目
Projects from Git >git clone URI(填写github上的项目https网址即可)。
2、提交github
右键项目 team - > Commit -> Commit and Pust既Commit 到本地仓库,又Push到远程github
3、单个文件回滚(本地)
右键文件 team -> Show Local History 在右侧Revison Time栏里 选择欲回滚版本 ->右键 get Contents
4、整体项目回滚(本地)
右键项目 team - > Show in History 在右侧History栏里,选择欲回滚版本 右键 -> Reset -> 选Hard模式即可。另外两个没试验过。
5、回滚后,想恢复原高版本(本地)
右键项目 team -> pull拉至原最新版本,在History中所有操作的版本又都出来了。
6、建立分支 合并
建立:右键项目 team -> Switch to ->New Branch建立一个新的分支。新的分支可以进行添加 修改等操作。然后 Commit到本地,并push到github
合并: swith to master,然后Merge -> 选Local下面的分支,然后ok。这样就在本地合并了。Push Branch Master可以push到github
基本概念
fetch //将代码从远程仓库拿到本地仓库
pull //将代码从远程仓库拿到本地工作空间
commit //从本地工作空间提交到本地仓库
push //将代码从本地仓库提交到远程仓库
常用命令:git status 查看被修改的文件
git checkout -- <filename>
撤销当前工作区的修改到最近一次执行命令git add or git commit的时候,即若修改之前没有执行git add就回退到最近提交(git commit)的时候,如果之前执行git add则会回退到最新提交到暂存区的版本。
注意:git checkout 如果没有后面没有“--”,就是切换分支的命令。
git checkout -b <branchname>:新建分支branchname,并切换至改分支。
git reset --hard <版本号>
设置到指定版本
git log --pretty=oneline
查看历史版本
git reflog
显示版本变动的命令
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
git log --graph命令可以看到分支合并图
合并分支不使用fast forward:git merge --no-ff -m "merge with no-ff" dev
git stash:保存现场
git stash list: 查看保存文件
git stash apply:恢复现场,但不删除保存的内容
git stash pop: 恢复现场并删除stash内容
git push origin branch-name:?从本地推送分支
git checkout -b branch-name origin/branch-name:?在本地创建和远程分支对应的分支
git branch --set-upstream branch-name origin/branch-name:?建立本地分支和远程分支的关联
http://www.open-open.com/lib/view/open1328069733264.html
http://www.open-open.com/lib/view/open1328069889514.html
http://www.ruanyifeng.com/blog/2012/07/git.html