首页 > 其他分享 >Git相关

Git相关

时间:2022-11-22 18:01:14浏览次数:46  
标签:origin Git -- 标签 git push 相关 分支

git命令
ssh-keygen -t rsa                                  生成ssh公私钥
git clone 地址                                      git下载源码

git status                                         查看状态
git pull origin <branchname>                       更新代码
git push origin <branchname>                       推送代码
git diff <filename>                                查看修改内容
git push origin --delete <branchname>              删除远程分支:
git push -f                                        强制推送远程回滚

git add <filename>                                 添加代码到暂存区
git commit -m  "注释"                              提交代码到版本库
git commit -a -m  '注释'                           添加并提交到版本库

git log <--pretty=oneline>                        查看历史记录
git reflog                                        查看历史记录(包含已回退的)

git checkout -- <fileName>                        还原工作区文件
git reset HEAD <fileName>                         还原文件暂存区到工作区
git reset --hard HEAD^ <HEAD~1>                   还原已提交未推送远程的文件
git reset --hard <版本号>                          还原文件到某个版本
git reset -–hard origin/master                    回退到和远程一样

git branch -m <oldname> <newname>                 修改本地分支名称
git branch -d <branchname>                        删除本地分支
git branch -D <branchname>                        强制删除分支

git branch <-a>                                   查看分支
git checkout <branchname>                         切换分支
git checkout -b <branchname>                      创建+切换分支
git log --graph --pretty=oneline --abbrev-commit  查看合并的分支图表

git merge <branchname> <--no-ff(生成节点)>        合并某分支到当前分支
git cherry-pick commitid                         合并某一次提交到当前分支

git tag <tagName> <commitId> -m "comment"        添加标签
git tag                                          标签列表
git show <tagName>                               标签详细查看

git push origin <tagName>                        提交单个标签到远程
git push origin --tags                           提交全部标签到远程

git tag -d <tagName>                             删除本地标签:
git push origin --delete tag <tagName>           删除远程标签

git stash                                        当前工作现场存储起来
git stash list                                  工作现场存储列表
git stash pop                                   恢复工作现场(删除储藏)
git stash apply                                 恢复工作现场(不删除储藏)
git stash drop                                  手动删除储藏

git cherry-pick commit11  commit2               同时提交多个
git cherry-pick commit11..commit2               左开右闭
git cherry-pick commit1^..commit2               左闭右闭

标签:origin,Git,--,标签,git,push,相关,分支
From: https://www.cnblogs.com/rbcd/p/16915954.html

相关文章