在git中,一定不要去尝试修改远程服务器的提交历史,因为所有人都维系着同一份历史,如果你擅自修改后,别人的记录就对不上了,接下来对代码仓库的同步就会出错;
GitKraken(6.14version)
Amend # 仅在本地操作,当前修改提交到上次commit上(不创建新的commit)
Branch # 工具栏Branch,分支创建|合并到master|push
Stash # 暂存,区别于Stage,工具栏Stash,左侧STASHES有所有暂存的未提交的代码,工具栏Pop用来恢复暂存;Stash本质上同merge,可以跨分支恢复暂存
Rebase # 变基,类似merge,与merge的区别是将一分支取下来嫁接至另一分支使成一条直线(不出现分叉,而merge会记录清楚原先每次的提交),变基后在最新的commit上右键用fast-forward将master指针指向到最新的提交,最后push;
Pull(rebase) # 工具栏的Pull(rebase)
Checkout # 签出,用于查看之前的代码,在老的提交上Checkout,修改代码后,HEAD会指向这个提交(因为当前脱离分支状态,HEAD表示当前处于这个提交),提交后在最新的提交上右键选master-->Rebase HEAD onto master,最后fast-forward到最新提交上
Undo # 撤销,工具栏Undo,针对本地代码仓库的修改(如果已提交到远程就不能这么做了),每次对git的操作都会记录至reflog引用日志,点一次即撤销了上次的更改(更改可以是分支的切换|合并|修改|删除等)
Redo # 重做
Revert # 恢复,用于撤销已提交的代码(Revert不直接修改提交历史,而是生成一个与之前提交完全相反的新提交,这对远程仓库中提交的撤销很有用),在要撤销的提交上右键Revert commit,会提示Do you want to immediately commit the reverted changes?是否创建一个新的提交,选是
gitkraken使用gitflow:
File-->Preferences-->Initialize Git Flow # Configuration, First initialize Gitflow in Preferences, Gitflow and change the default branch names if desired. Once initialized, two branches will always be present, master(The version in production) and develop(The version currently in development for the next release). Changes are merged into these branches, if you do not currently have these branches in your local repository, GitKraken Client will create them when Gitflow is initialized
# Usage
With Gitflow initialized in your repo, you will get an additional menu in the left panel. Start or finish any of your Gitflow branches here.
Create new Gitflow branches by clicking the green button on the Gitflow menu on the left.
Or whenever you add a branch, include the prefix for the Gitflow branch type i.e.
feature/branch-name. Any branches that do not have the prefix, will be displayed in the local repository seciton, but not in the Gitflow menu.
Note: Gitflow has the benefit of adding all features, hot-fixes, and release branches in different folders.
Gitflow branches can be pushed to a remote which is the same as 'Publishing' the Gitflow object in the command line.
如当前在feature/new-element分支上,右键Finish feature/new-element-->Finish Feature;
# Feature
Feature branches are used for new features or bug fixes. They typically exist only in local repos and aren't shared with others.
When finishing a feature branch, GitKraken Client will merge the feature branch into develop, and delete the feature branch from the local repository.
You also have the option to rebase the feature branch on top of develop.
如当前在release/v1.0.0分支上,右键Finish release/v1.0.0-->Finish Release;
# Release
Releases are major and minor versions of your product. They're often shared with other collaborators working on the same version.
When finishing a release, the release branch is merged into both master and develop branches. This creates a tag with the release name for future reference.
如当前在hotfix/UI-issue分支上,右键Finish hotfix/UI-issue-->Finish Hotfix;
# Hotfix
Hotfixes are the same as Releases in Gitflow, except hotfix branches are created on top of master,while release branches are created on top of develop.
Hotfixes are for quickly pushing out a change to your production branch. Common examples of hotfixes are fixing typos, and bugs that need to be pushed out as soon as possible to production.
When finishing a hotfix, GitKraken Client will merge the changes into both master and develop.
如当前在release/1.0.0,右键Finish release/1.0.0-->Finish Release;
# Tag
Tags are used to mark a specific point in the repository's history. They are often used to mark a release.
Tags can be created from the Gitflow menu, or from the command line. When creating a tag from the Giflow menu, GitKraken Client will create a tag with the same name as the branch. For example, if you create a tag from a release/1.0.0 branch, GitKraken Client will create a tag named 1.0.0. Additionally, you can add a tag message when fishing a branch. This message will be added to the tag.
In Preferences-->Gitflow, you can set a tag prefix. This prefix will be added to the tag name when creating a tag from the Gitflow menu. For example, if you set the tag prefix to v, and create a tag from a release/1.0.0 branch, GitKraken Client will create a tag named v1.0.0.
另图形化工具SourceTree|SmartGit|TortoiseGit;
除github,另gitlab|BitBucket|国内Gitee;