git老爹是牛惨了的linux之父,windows下的git bash就是基于linux做的,我学这个git前后花了几个月,都是时不时看一点,今天把自己以前学的个人理解纪录一下~,估计认真学的话最多 一天两就学会了。下面就是一些命令操作,对于不会linux的同学是硬伤~哈哈,去官网下载对应系统的最新版本,运行git bash
本地操作
git add -A or git add –a or git add . //It means to add all files which are unstaged
先cd到工程文件夹下!
git init //即把该 文件夹变成了一个仓库
git add ~ //添加进去!
git status //当前仓库的状态
git commit -m “~~” //真正的提交
git commit -a //添加所有到仓库
git branch //即能看到分支
git checkout branchname //移动到分支上
git branch -d branchname //删除某个分支
git diff //如果还没有commit的话,可以查看哪些文件被修改了
git merge branchname //合并当前分支与branchname
git push // 用于远程推送
git log//显示项目进展日志
git relog//显示所有操作日志
git reset -–hard HEAD~100 //回退到100个版本前
git reset –hard HEAD^ //回退上一个版本 回退上上个就HEAD^^以此类推
分支操作和远程
git clone xxx -b remote-branch –single-branch //克隆特定分支
git fetch origin dev:dev //从远程的dev到当前dev,本地不存在就创建一个dev分支
git diff dev //当前分支与dev分支的区别
git merge dev //合并当前分支与dev分支
git branch -a //查看远程所有分支
git branch branchname //本地新建分支
git branch -d branchname //本地删除分支
git checkout branchname //本地切换分支
git remote add origin httpsaddress or sshaddress //与远程端建立关联
git push origin branchname //将新的分支发布在github上,前提是先要与远程端关联,而且还是本地有的分支
git push origin branchname:branchname //我喜欢用这个方式推送
git push origin :branchname //远程端删除这个分支!
git remote -v //查看远程连接地址
git clone -b branchname httpsaddress or sshaddress –single-branch//远程只克隆一个分支到到本地
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
// 获取远程所有分支!
Tips1:合理的使用分支让你的项目进度更加清晰明了
Tips2:所有不会的命令直接 git –help,如git branch –help
更多文章:http://blog.csdn.net/what951006?viewmode=list
powered by:小乌龟在大乌龟背上