Git操作手册记录

Git使用指南

1.查看历史tag
git log --pretty=oneline --abbrev-commit //查看历史tag

git tag //查看历史tag

git show <tagname> //查看指定tag指的commit内容

git tags --push //推送本地tag

git fetch origin tag <tagname> //获取远程tag

2.暂存
git stash //暂存本地修改

git stash list //查看当前储藏
stash@{0}: WIP on master: 049d078 added the index file

git stash apply stash@{2} //应用指定的储藏

git stash pop //应用暂存内容

git stash apply //应用暂存内容 不删除stash

1.场景1:应用储藏后修改文件后想撤销储藏
git stash show -p stash@{0} | git apply -R
2.场景2:储藏之后修改文件,想应用储藏,可能会有冲突,应用储藏时把储藏应用在新建分支上
git stash branch testchanges

3.分支
git reset --hard HEAD^ //回退版本,HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id。

穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。

要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本。

git checkout -b dev_zhengwang orgin/dev_zhengwang //新建本地分支跟踪远程分支

git branch -u origin/dev_zhengwang //切换跟踪远程的分支

git fetch origin //将本地origin/dev_zhengwang远程跟踪分支和远程分支同步

git branch -vv //查看本地分支和远程跟踪分支指向的commit的区别

git push origin dev//推送本地dev分支到远程

git branch -m <oldname> <newname> //分支重命名

git branch -m <newname> //当前分支重命名

git checkout branch-name //切换分支

git commit -m 'comment info' //提交信息

git checkout -b 'branch-name' //切换到新分支

git push --set-upstream origin DEV_20171012_apollo
//重命名远程分支
$ git branch new-branch-name origin/old-branch-name
$ git push origin --set-upstream new-branch-name
$ git push origin :old-branch-name //删除远程old-branch-name分支
4.回退

git log //查看历史commit

git reset --hard commitid

git reflog //查看未来commit

git reset HEAD file //把暂存区的修改回退到工作区

git checkout -- file.txt //把文件从工作区回退到工作区之前干净状态

5.git忽略文件权限的变化
git config core.filemode false

6.每过一个发版日都需要合并一次master分支

7.reg tag打在dev分支上,在reg

猜你喜欢

转载自www.cnblogs.com/zhengwangzw/p/9212269.html
今日推荐