Teach you to use Git in the IDEA code version management

1, Git Introduction

Git is a popular distributed version control system.

It has two sets of repository, the local library and the remote database, these two sets of repository independently of each other when not in operation, and deletion of the merger. Therefore almost all of its operations are performed locally, so that the code can still be submitted in the case of disconnection, branch switching.

Git and using a SHA-1 hash algorithm ensures becomes incomplete at the time of file transfer, disk damage caused by data loss can be immediately perceived.

1.1 Git basic workflow:

  • git clone: ​​The Master remote branch code cloned into the local repository;

  • git checkout: cut branches off development;

  • git add: the document to join the tracking area;

  • git commit: changing the tracking area to be submitted to the library code into native code library;

  • git push: to be submitted to the local repository code in the remote repository.

1.2 Git branch

  • Main branch:

    • master branch: the code stored ready for deployment in a production environment;

    • develop branches: the latest developments of the current store branch, when the code is stable enough to be merged into the master branch up.

  • Auxiliary branches:

    • feature branches: the development of new functional use, eventually merged into the develop branch or discarded;

    • release branches: a small defect correction, the information needed to prepare the release of version;

    • Emergency repair work code: hotfix branch.

2, Git usage

Focuses of this paper is applicable in for IntelliJ IDEA.

Configuration Git down 2.1 IntelliJ IDEA

2.2 git clone

  • VCS --> Git --> Clone

  • Enter your remote repository address, click on the test address is correct

2.3 git checkout

  • In the lower right corner of IntelliJ IDEA has managed a branch git, click. You need to choose a branch, checkout out

  • checkout it will be displayed at the bottom of the current branch. 1 being displayed in the local repository of version 2 remote repository version

  • Click the down arrow of the IDE VCS upper right corner, the change is synchronized to the local branch

2.4 git diff

  • Select the file than to the local changes, right select show diff will be able to view the changes in the file. Select Revert to give up or change file

2.5 git diff

  • Select Log In Version Control, you can view the submission history

2.6 git diff

  • The default import library project has been added to git add the tracking area;

  • Just modify pom.xml file, the modified file will be displayed in local changes in Version Control;

  • Click the up arrow in the upper right corner of the IDE's VCS, git commit, write logs submitted to the local code base;

2.7 git diff

  • VCS -> Git -> Push, native code will be submitted to a remote repository

 

3, common commands

Press [Alt] + [F12], IDEA enter command line mac.

Git use IDEA in the command line, the command used is as follows:

  • clone project: git clone xxxxxx
  • Check project status: git status
  • And remote handover branch associated with the branch: git checkout -b xxx -t origin / xxx
  • Pull the latest updates: git pull
  • Submit updates: git commit -am "Remarks"
  • Merge branch to the current branch to be switched to the first combined branch: git checkout xxx, recombined git merge yyyy
  • Submit: git push

 

More exciting, please pay attention to my "Today's headlines No": Java cloud notes
anywhere, so you have the latest and most convenient Pocket Cloud Services

Published 165 original articles · won praise 270 · views 80000 +

Guess you like

Origin blog.csdn.net/weixin_44259720/article/details/104674433
Recommended