This is the 9th day of my participation in Gwen Challenge

Common version control tools

  • GIT

  • SVN

  • CVS

    Adhering to a principle: learning we must be learning the most popular

1, before the words,

GIT version control benefits

1. Realize cross-regional multi-person collaborative development

2. Track and record the history of one or more files

Organize and protect your source code and documentation

4. Count the workload

5. Parallel development to improve development efficiency

6. Keep track of the software development process

2. Classification of version control

(1) Local version control

Record each update of the file, can make a snapshot of each version, or record, suitable for individuals

(2) Centralized Version Control (SVN)

All version data are stored on the server, and developers can synchronize updates or upload their own modifications from the server. Users only have their own previously synchronized versions locally. If they are not connected to the network, users can not see the historical version, nor can they switch versions or branch

Distributed Version Control (GIT)

Everyone owns all the code! Safe hidden trouble

All version information warehouse all synchronized to the local each user, you can view all versions in the local, can be offline local submission, not because of server or network problems, resulting in failure to work

Differences between GIT and SVN

The SVN is a centralized version control system. The version library is centralized on the central server. The SVN obtains the latest version from the central server every time

GIT is a distributed version control system. There is no central server. Everyone’s computer is a complete version repository.

3. Basic theory of Git

Git has three local workspaces,

WorkSpace: The area where you normally store project code

Index/Stage: the staging area, which is a temporary place to store your changes, is actually a file

Repository: go to a local Repository, a secure place where all versions of your data are stored

(Remote) : A server that hosts code and can simply be thought of as a computer on your project team for Remote data exchange

Corresponding command:

Git commit -> local repository -> Git push -> remote repository

4. GIT file status

Untracked: not tracked – > Git add. – > Staged

Unmodify: the snapshot content in the version library is the same as that in the folder

Modified: The file has been Modified, git Add entered passively, git checkout discarded, and return — >Unmodify

Passage Ten: Staged state

5, branch

#Lists all local branches
  git branch
#List all remote branches
  git branch -r
#Create a new branch, but remain in the current branch
  git checkout [new-branch]
#Create a new branch and switch to it
  git checkout -b [new-branch]
#Merges the specified branch into the current branch
  git merge master
#Deleting a Local Branch
  git branch -d [new-branch]
#Deleting a Remote Branch
  git push origin --delete [new-branch]
Copy the code

6, commonly used

#Deleting a Local Branch
  git branch -D test 
#Deleting a Remote Branch
  git push origin --delete test
#To the specified COMMIT record
  git reset --hard commitId
#Remote pull code
  git fetch origin master
#Merges specified commits
  git cherry-pick 62efcd
#Git moves from one repository to anotherGit remote add origin2 master Git remote set-url origin2 http://xxxx.git git push origin2 Origin2: Master branch commit master repository to Origin2: Master branch#Unassociate a remote library from a local directory
  git remote remove origin
#The remote branch has been removed, but Git branch -a is still displayedGit branch -r 2: check the relationship between the local branch and the remote branch. Git remote show origin 3: Delete all the remote branches#Modify commit commit commentsGit commit --amend (amend the last commit comment)#Standard git command (Merge scheme)Git add * - add to cache git commit -m 'Commit to local repository git pull origin dev' git push Git checkout branch_stg_one git merge devCopy the code

7, the configuration

#User name, NPM image configuration
  git config --global user.email 'xxxx.com.cn'
  git config --global user.name 'xxxx'
  npm config set registry https://registry.npmjs.org/
  npm config set registry http://registry.npm.taobao.org/
  
#Git short for configuration1, CD ~ root directory 2, ls -al view all hidden files in the root directory 3, vim. Gitconfig  [user] name = zhengliming email = [email protected] [alias] br = branch st = status co = checkout ci = commit ps = push pl = pull mg = merge line = log --oneline pre = log --pretty=oneline cp = cherry-pick sa = stash tree =  log --graph --pretty=oneline --abbrev-commit [pull] rebase = true  
#View the archive for details
  git log -p
#View details of the last change to the archive
  git show
#Add a file to the staging areaGit add. All changes are committed to the staging area, but not the deleted files, and will be filtered based on.gitignore. Gitignore adds any files to git add -u and commits the modified files to the staging area. Git add-a commits all changes#Git stash cacheWhen you are developing on Dev, there is a bug in the project and you need to fix it urgently, but your project is just finished and you don't want to mention it yet. In this case, you can use the git stash command to save the changes to the stack, and then smoothly switch to the Hotfix branch to fix it. Because of this mistake, you need to go back to dev with the git stash stash stash to save the dev stack. When you go back to dev, restore the dev stack again. Stash @{0}: On ZLM: 0227 Stash @{1}: WIP On master: 4, Git Stash pop Pop the stash contents and apply them to the working directory of the current branch. Stash @{0} puts the contents of the stack in the current directory. Unlike git stash pop, this command does not remove the contents from the stack. It can be used for multiple branches. Stash @{0} removes the specified stash 7 from the stack, and clears the contents of the stack with git stash 8. Git stash show stash@{0} See the difference between the specified stash and the current directory 9, git stash show stash@{0} -p See the difference in detail 10, Git Stash branch creates a branch from the latest stashCopy the code