=========Git 命令==start======
git status //检查代码状态
git clone git@。。。。 //检出工程
git fetch //抓取工程远程新分支等
git pull //拉取代码
git push (origin xxx) //提交
git checkout xxx //检出git中的工程
git commit //提交代码
git commit -m "修改内容" .
git commit --amend //补充commit说明
git commit -a //强行提交
git stash //缓存修改过的代码,然后可以切换到别的分支
git stash pop //切换回修改分支时,恢复代码
git stash save "描述"
git reset --hard //恢复没有add的文件
git reset --hard commitId //回滚到指定commitid
git reset xxxx^ //恢复commit的文件(一个^表示恢复到xxx的一个,没有表示恢复到xxx,^^ 表示恢复到前两个版本)
git reset HEAD^ //表示最近一次的commit
git mergetool
git checkout -- . //checkout 出所有没有提交的代码
git log --pretty=oneline //显示一行提交日志
git log stat //显示提交日志的具体类变化
git status -s //只显示被修改的文件
git diff > xxx.patch //导出未commit的代码形成patch文件
----------git branch 相关start----------
显示本地分支,有*号的是当前分支:
git branch
显示远程分支:
git branch -r
显示全部分支(本地+远程):
git branch -a
创建分支:
git branch xxx
切换分支:
git checkout xxx
创建+切换分支:
git checkout -b xxx
删除分支:
git branch -d xxx
删除远程分支:
git branch -r -d origin/branch-name
git push origin :branch-name
合并分支:
git merge xxx //合并xxx分支到当前分支
git merge xxx yyy //合并xxx分支和YYY分支,到当前分支。
合并xxx分支到master分支:
git checkout master //如果当前分支不是master,先切换到master分支。
git merge xxx //合并xxx到当前分支。
也可以在过去的某个点拉一个分支:
git branch 分支名 commitID
git push origin local_branch:remote_branch //提交本地分支到远程服务器
这个操作,local_branch必须为你本地存在的分支,remote_branch为远程分支,如果remote_branch不存在则会自动创建分支。
类似,git push origin :remote_branch,local_branch留空的话则是删除远程remote_branch分支。
git branch --set-upstream-to=origin/local_branch remote_branch //关联本地和远程分支
=======window 命令start========
touch xxx.txt // 生成名为xxx.txt的空文件
pwd // 显示当前目录路径
rm xxx.txt // 删除xxx.txt文件
mkdir xxx // 建立xxx目录
rm -r xxx // 删除xxx目录
mv xxx(目录) // xxxxxxxx(目录)
cp -rf xxx yyy//拷贝代码 ,从xxx中拷贝到yyy中
网友评论