1, git branch usage:
View branch: git branch
Check local and remote branch: git branch -a
Creating a branch: git branch version1.0 (branch name)
Switch to the specified branch: git checkout version1.0 (branch name)
The branch code merge: git checkout master
git merge version1.0
Delete local branch: git branch -d version1.0 (branch name)
To delete a remote branch: git push origin --delete version1.0 (branch name)
2, git pull remote project steps:
(1) clone project to the local
git clone <projectAddress> (Project Site)
(2) into the project directory
cd <projectname> (project name)
(3) create a local branch to remote branch project
git checkout -b dev (local branch name) origin / dev (remote branch name)
(4) pull into a local project
git pull origin dev (remote branch name)
git pull
Both commands can be downloaded to complete the project
If the local branch has been created, you can switch directly to the appropriate branch: git checkout dev (local branch name), git pull
3. Pull the previous version of the project:
(1) View History committed version: git log
Gets want to roll back the version of history commit Id
(2) version rollback:
git reset --hard <commitId> (historical version id)
The instructions indicate that version will change commitId retreated pointed
4. submit code to a remote repository:
(1) view the current status of which has been modified
git status
(2) submit what code
git add. Or git add -a (submit all code)
(3) commit
git commit "commit"
Here the "commit" can also set up their own: for example, you want to have each commit themselves to set a fixed format (git commit template template set)
- New template files in the root directory: xxxx_template: as follows
- Set Template command is as follows
git config commit.template [template file name] // This command can only be set to submit a template of the current branch
git config --global commit.template [template file name] // This command can set the global submission template, note that the previous global two bars
- Set Text Editor
git config --global core.editor [editor name]
Provided, for example notepad ++: git config --global core.editor D: / Editplus / Notepad ++ / notepad ++ exe.
(4) Code Submit
git push origin HEAD: refs / for / <name> (filed branch name)
5. When the provisional tasks need to switch to another branch, the need to save the current operation in this branch
(1) Save temporary modifications:
git stash save "to save the name."
git stash
(2) Get all the backup git stack
git stash list
(3) get the case last modified, last saved reading the contents of the stack from git
git stash pop
A queue using any stored temporary modification
git stash apply stash @ {2} // save the use of the modified common_for_CT01
Empty git stack:
git stash clear
6.其他的一些git指令
git diff 的使用:查看最近修改的不同
- 修改文件内容还未执行add命令
git diff <filename> //查看最近一次提交的版本
- 执行add命令还未执行commit指令
git diff HEAD --<filename> //查看工作区与最近一次提交的版本库里面的区别
- 执行add命令并且commit后
git diff HEAD^ --<filename> //查看最近两次提交版本的区别