Writing in the front

For anyone who has done software development on a team, version control is a must. Currently, version control is mainly divided into centralized version control system and distributed version control system, known as SVN and Git. Git is one of the most popular distributed version control systems, so today, we’ll take a look at some of the wonders of Git.

The difference between SVN and Git

  • Basic: SVN is centralized, Git is distributed. Centralized, the version library is stored centrally in the central server. When working, everyone needs to get the latest version from the central server first, and then work in their own branches. After completing the work, they submit it to the central server. Distributed, each computer is a complete version of the library, can reduce the central server to hang up the serious consequences. Git is a collection of SVN servers and clients.
  • Different networking requirements: In Git, version iteration information and branch creation can be seen without networking, while SVN can meet the above requirements only when it is networked.
  • Different levels of difficulty in branch management: On the SVN, branches serve as a directory in the version library. To check whether to merge branches, you need to run themsvn propget svn:mergeinfoInstruction; In Git, you can quickly switch between branches and merge quickly.
  • Different storage modes: SVN stores files, Git stores metadata.
  • Permission problem: On the SVN, you can set the permissions of each account, such as read-only and read-write permissions, but Git has no corresponding permission control. This is probably why some companies still have SVN.
  • Summary: Tools always have a focus. There is no good or bad, only what is needed.

Install Git

  • The first method: install Git graphical management tool – SourceTree, do not have to remember so many commands, understand the basic process can rest assured to use, download this;
  • The second method is to install Git on a Mac. You can use HomeBrew to install Git. For details, refer to HomeBrew documentation.
  • Please refer to this for additional installation methods for other platforms.
  • If you are not familiar with Mac terminal commands, you can refer to my previous article: Learn Mac common commands, help iOS development

The use of Git

There are two ways to use Git. One is through terminal command control, and the other is using Git’s graphical management tool, SourceTree. Which of the two is more useful and efficient depends on the individual. The author will introduce the basic operation of these two methods respectively below, hope readers can read while hands-on operation, benefit a lot.

Git command
1. Create version library:
  • First, choose a suitable place to create an empty directory:
      Mac-Pro:~ kys- 1$ mkdir gitTest
      Mac-Pro:~ kys- 1$ cd gitTest
Copy the code

Or directly in the corresponding directory, manually create a folder;

  • Second, input on the terminalgit initCommand, as follows:
      Mac-Pro:~ kys- 1$ cd /Users/kys- 1/Desktop/gitTest
      Mac-Pro:gitTest kys- 1$ git init
      Initialized empty Git repository in /Users/kys- 1/Desktop/gitTest/.git/
Copy the code

Thus, a local warehouse was successfully built.

  • Finally, each time a repository is created, one more directory is created for the current directory.gitDirectory, if you don’t see it, just use itls -ahCommand:
      Mac-Pro:gitTest kys- 1$ ls -ah
      .		..		.DS_Store	.git
Copy the code

It is clear that the author’s current directory has two hidden ones.

2. Add files to the version library
  • First, create oneGitTest.mdFile, as follows:
      git is a strong software
      Let's start with a good mood!
Copy the code

Place the file in the same directory as the repository gitTest;

  • Secondly, usegit addCommand to add a file as follows:
      Mac-Pro:gitTest kys- 1$ git add GitTest.md
Copy the code

It then executes, and if no information is displayed, it is running correctly;

  • Finally, use the commandgit commitSubmit the file to the warehouse as follows:
        Mac-Pro:gitTest kys- 1$ git commit -m "wrote a README"
        [master (root-commit) dfaeb43] wrote a README
           1 file changed, 1 insertion(+)
           create mode 100644 GitTest.md
Copy the code

-m is followed by details about the submission, such as which feature was completed or which bug was fixed.

3. Check the warehouse status
  • First of all, the submittedGitTest.mdModify the information in, then rungit status, the effect is as follows:
      Mac-Pro:gitTest kys- 1$ git status
      On branch master
       Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
       (use "git checkout -- <file>..." to discard changes in working  directory)

	      modified:   GitTest.md

      no changes added to commit (use "git add" and/or "git commit -a")
      
Copy the code
4. View the modification
  • Using the commandgit diffYou can view the modified content as follows:
      Mac-Pro:gitTest kys- 1$ git diff
      diff --git a/GitTest.md b/GitTest.md
      index 00ad777..64590e1 100644
      --- a/GitTest.md
      +++ b/GitTest.md
      @@ - 1 +1.2 @@
      -git is a strong software
      \ No newline at end of file
      +git is a strong software
      +Let's start with a good mood!
      \ No newline at end of file
Copy the code
5. Roll back the version
  • First, usegit logRun the following command to view historical records:
       Mac-Pro:gitTest kys- 1$ git log
       / / version
       commit 988f92f1f5cf959d491ad63462e0c90372bb4b0b
       Author: XiaolinSun <401788217@qq.com>
       Date:   Fri Apr 8 11:15:08 2016 +0800
    
           add new
       / / version 2
       commit dfaeb438504942d09e7f4282bd93b560d2ee68e2
       Author: XiaolinSun <401788217@qq.com>
       Date:   Fri Apr 8 11:12:02 2016 +0800
    
         wrote a README
       Mac-Pro:gitTest kys- 1$ git reset --hard HEAD^
       HEAD is now at dfaeb43 wrote a README
       Mac-Pro:gitTest kys- 1$ git log
        / / version 3
       commit dfaeb438504942d09e7f4282bd93b560d2ee68e2
       Author: XiaolinSun <401788217@qq.com>
       Date:   Fri Apr 8 11:12:02 2016 +0800"Wrote a README". Among them, the `988f92 f1f5cf959d491ad63462e0c90372bb4b0b ` a string of characters that the version number ` commit id `;Copy the code
  • usegit resetThe command can be rolled back to the previous version git reset --hard commit idThat is as follows:
 Mac-Pro:gitTest kys- 1$ git reset --hard 988f92f
 HEAD is now at 988f92f add new
Copy the code
  • If the development process, accidentally, back to the wrong place, can be usedgit reflogCommand to view the command history as follows:
      Mac-Pro:gitTest kys- 1$ git reflog
      dfaeb43 HEAD@{0}: reset: moving to HEAD^
      988f92f HEAD@{1}: commit: add new
      dfaeb43 HEAD@{2}: commit (initial): write a single string at the end of the string.Copy the code
6. Work area and temporary storage area
  • Workspace: The file directory created on the computer in the previous steps is the workspace, as shown below:

  • Version libraries are hidden directories.git;
  • When adding a file, first, use thegit addTo add a file to, you actually add the file changes to the staging area; Then, usegit commitTo commit changes, you commit the contents of the staging area to the current branch. Finally, every time the file is modified, if notaddTo the staging area. That’s not joiningcommit.
7. Undo the modification
  • Git is a strong software Let’s start with a good mood! Start up now! Fight for future! At this point, you must check the status: type git status as follows: Mac-Pro:gitTest kys-1$ git status On branch master Changes not staged for commit: (use “git add …” to update what will be committed) (use “git checkout — …” to discard changes in working directory)

      modified:   GitTest.md
    
    no changes added to commit (use "git add" and/or "git commit -a")
    Copy the code
  • Git checkout — file: $git checkout — gittest.md $git checkout — gittest.md

      git is a strong software
      Let's start with a good mood!
      Start up now!
Copy the code

At this point the content is restored.

8. Delete files
  • usegit rmAnd ` ` git commitCommand to delete the corresponding file from the repository, for example: let's create a new oneThe newfile.md ‘file, and then add it to the workspace as follows:

      Mac-Pro:gitTest kys- 1$ git add newFile.md
      Mac-Pro:gitTest kys- 1$ git commit -m "add newFile"
      [master e278be1] add newFile
       1 file changed, 1 insertion(+)
       create mode 100644 newFile.md
      Mac-Pro:gitTest kys- 1$ git rm newFile.md
      rm 'newFile.md'
      Mac-Pro:gitTest kys- 1$ git commit -m "delete newFile"
      [master 9c28795] delete newFile
       1 file changed, 1 deletion(-)
       delete mode 100644Newfile.md After executing these commands, the file is deleted from the repository.Copy the code
The subtotal

All of this is done in the local repository. If it feels a bit verbose, just remember the following commands:

	1.Git init ------- create an empty version library.2.Git add ------- add files to the staging area;3.Git commit ------- Commit files to a repository.4.Git status -------5.Git diff -------6.git log------- View the submission history.7.Git reset ------- back to previous version;8.Git reflog ------- View command history.9.Git checkout ------- discards workspace changes;10.Git rm -------Copy the code
Two. The use of SourceTree
  • Use the SourceTree client to perform the local warehouse-related operations described above.
  • Install and open SourceTree:

  • chooselocalButton, after clickThe new warehouse, the choice ofCreating a local repository, fill in your address and clickcreateIs it convenient? :

  • So LET me create a nameTTestTo demonstrate the following operations, click on the navigation bar of the new warehouse:

  • Add files in the workspaceREADME.md:

To explain,Has the stagingIs equivalent togit addOperation.

  • Submit operations, comparegit commit -m "add new info"Command:

  • View the specific content modification, view the relevant status can be directly seen, will not be repeated one;
  • Go back to the previous versionA rollback operation, select the specific submission record, right click, and selectCommit rollbackCan;
  • Compare that and findSourceTreeIt’s so convenient and fast!
Remote warehouse
  • Concept: The remote repository can use a computer as a server from which the rest of the team can clone a complete process to their own local repository, and push the completed parts to the remote repository for project follow-up. For demonstration purposes, I’ll use Github, an off-the-shelf remote repository;
  • As a developer, a Github account is a must, and if you don’t already have one, you should create one immediately.
  • Create an SSH Key because the local Git repository is encrypted over SSH with the Github remote repository. First, you need to go to your home directory to see if there is any.sshDirectory, and look again.sshDo you have it in the directoryid_rsaandid_rsa.pubThe file, as follows,

If the above two files are not found, you need to create:

Mac-Pro:~ kys- 1 $ ssh-keygen -t rsa -C "[email protected]"  
Copy the code

You need to change your email address to your own, as follows:

	Mac-Pro:~ kys- 1$ ssh-keygen -t rsa -C "[email protected]"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/kys- 1/.ssh/id_rsa): 
    Created directory '/Users/kys-1/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /Users/kys-1/.ssh/id_rsa.
    Your public key has been saved in /Users/kys-1/.ssh/id_rsa.pub.

Copy the code

Pub = id_rsa.pub = id_rsa.pub = id_rsa.pub = id_rsa.pub = id_rsa.pub = id_rsa.pub = id_rsa.pub

  • Log in to your Github account and open itAccount settings.SSH KeysPage, addid_rsa.pubContents of the document:

  • Add an SSH key to ensure that the project is modified by someone else and that the submission pushed to the remote repository is actually submitted by you.

  • To add a remote repository, log in to github and click the “New Repository” button to create a New repository:

You need to fill in the warehouse name, description and whether to select create initialization file, etc.

  • Run the following command in the local repository:
Mac-Pro:~ kys- 1$ git remote add origin yourGitAddress
Copy the code

Then, push all the contents of the local library to the remote library:

Mac-Pro:~ kys- 1$ git push -u origin master
Copy the code

At this point, as long as you commit locally. You can run the following command:

Mac-Pro:~ kys- 1$ git push origin master
Copy the code

Push the latest changes to the local master branch to GitHub.

  • usegit cloneCommand to clone the remote library locally:
Mac-Pro:~ kys- 1$ git clone yourLocalGitAddress1
Copy the code
  • Clone a remote repository from SourceTree

The source URL is the address of the remote repository, and the destination path is the path of the local storage.

Create and merge branches (compare with SourceTree synchronization)
  • Concept: create branch’s aim is to make your work becomes more flexible and more efficient, when you develop new function, you create a branch, you can continue to work in the original branch, also can work in the new branch, it will not interfere between, when you have completed the new function, by incorporating new branch to branch. The most interesting thing about Git is how fast it is to create and switch branches.
  • createdevBranch, then switch todevBranch, usinggit checkoutCommand:
 Mac-Pro:gitTest kys- 1$ git checkout -b dev
 Switched to a new branch 'dev'
Copy the code

-b indicates the creation and switchover.

  • usegit branchCommand to view the current branch:
      Mac-Pro:gitTest kys-1$ git branch
        * dev
        master
Copy the code
  • SourceTree operation:

- We operate in the dev branch, modify the contents of the 'readme. md' file and commit:  ```c Mac-Pro:gitTest kys-1$ git add README.md Mac-Pro:gitTest kys-1$ git commit -m "dev branch" [dev 9be4a38] dev branch 1 file changed, 2 insertions(+), 1 deletion(-)Copy the code
  • SourceTree operation:

  • devBranch work finished, switch tomasterBranch,
      Mac-Pro:gitTest kys- 1$ git checkout master
      Switched to branch 'master'
      Your branch is up-to-date with 'origin/master'.
Copy the code
  • SourceTree operation:

Right click and selectCheck out the masterBranch.

  • usegit merge The instructiondevBranch work results are merged intomasterBranches:
	  Mac-Pro:gitTest kys- 1$ git merge dev
      Updating 2269ea8.9.be4a38
          Fast-forward
         README.md | 3 ++-
       1 file changed, 2 insertions(+), 1 deletion(-)

Copy the code
  • SourceTree Operation: SelectdevBranch, right click to selectMerge dev to masterCan,

  • usegit branch -d devCommand to removedevBranches:
Mac-Pro:gitTest kys- 1$ git branch -d dev
Deleted branch dev (was 9be4a38).
Copy the code
  • SourceTree Operation: SelectdevBranch, right click to selectDelete the devCan.
The subtotal
Git checkout -b <name> merge a branch with the current branch: Git branch -d <name>Copy the code
Conflict resolution
  • Create conflict: Create a new moleculeconflictAnd work on the new branch, modifyREADME.mdThe operation is as follows:
	  Mac-Pro:gitTest kys- 1$ git checkout -b conflict
      Switched to a new branch 'conflict'
      Mac-Pro:gitTest kys- 1$ git add README.md
      Mac-Pro:gitTest kys- 1$ git commit -m "make a conflict"
      [conflict 1bc6611] make a conflict
       1 file changed, 2 insertions(+), 1 deletion(-)
Copy the code

  • Switch to themaster, continue to modifyREADME.mdContent and submit for modification:
      Mac-Pro:gitTest kys- 1$ git checkout master
      Switched to branch 'master'
       Your branch is up-to-date with 'origin/master'.
      Mac-Pro:gitTest kys- 1$ git add README.md
      Mac-Pro:gitTest kys- 1$ git commit -m "add two conflicts"
      [master f43d5d1] add two conflicts
       1 file changed, 2 insertions(+), 1Deletion (-) - Merge branches, and a conflict will occur: MAC-Pro :gitTest Kys- 1$ git merge conflict
      Auto-merging README.md
      CONFLICT (content): Merge conflict in README.md
      Automatic merge failed; fix conflicts and then commit the result.
      Mac-Pro:gitTest kys- 1$ git status
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)
      You have unmerged paths.
      (fix conflicts and run "git commit")
      Unmerged paths:
        (use "git add <file>..." to mark resolution)

	    both modified:   README.md

      no changes added to commit (use "git add" and/or "git commit -a")
Copy the code
  • Check the fileREADME.mdThe contents marked in red are used to mark the contents of different branches:

  • Just change the content to the following and resubmit.

We will make a conflict!

Mac-Pro:gitTest kys-1$ git add README.md Mac-Pro:gitTest kys-1$ git commit -m "comflict fixed" [master dad373b] comflict  fixedCopy the code

  • usegit log --graphYou can see the branch merge diagram;
  • Take a nap: Does this make you feel good about yourself?
Branch Management Strategy
  • Above merge branch, a large part is in useFast forwardThis mode has both advantages and disadvantages, that is, deleting branches will lose branch information, in this case, we need to use the normal mode, that is, with--no-ffthegit merge, continue the above process: Create branch dev-> Modify commit -> Switch branch -> Merge branch:
     Mac-Pro:gitTest kys- 1$ git checkout -b dev  / / * * *
     Switched to a new branch 'dev'
     Mac-Pro:gitTest kys- 1$ git add README.md / / * * *
     Mac-Pro:gitTest kys- 1$ git commit -m "add new content" / / * * *
     [dev 97676b7] add new content
      1 file changed, 1 insertion(+)
     Mac-Pro:gitTest kys- 1$ git checkout master  / / * * *
     Switched to branch 'master'
     Your branch is up-to-date with 'origin/master'.
     Mac-Pro:gitTest kys- 1$ git merge --no-ff -m"merge with --no-ff"  dev   / / * * *
     Merge made by the 'recursive' strategy.
      README.md | 1 +
      1 file changed, 1 insertion(+)
Copy the code
  • Of course you can use itgit log --graph --pretty=oneline --abbrev-commitCommand to view branch history:

  • A few additional points: First, in practical development,masterBranches are very stable and are only used to release new versions, but not to develop on them; Second, create dev branch development and wait until release time to merge intomasterBranch can; Everyone on the team has their own branch, which can be merged in time.

##### Add Bug branches

  • Above: Fixing bugs is inevitable, and fixing bugs can be done by creating a new temporary branch, merging branches, and deleting temporary branches.
  • Situation: When you are indevThe work is not finished on the branchBugIf you need to fix a Bug, you need to save your current work for a while and fix it as soon as possible.
        Mac-Pro:gitTest kys- 1$ git status
        On branch dev
        Changes not staged for commit:
        (use "git add <file>..." to update what will be committed)
          (use "git checkout -- <file>..." to discard changes in working   directory)

	    modified:   README.md

no changes added to commit (use "git add" and/or "git commit -a")
Copy the code
  • usegit stashTemporary current workspace:
      Mac-Pro:gitTest kys- 1$ git stash
      Saved working directory and index state WIP on dev: 40be6d0   merge with --no-ff
      HEAD is now at 40be6d0 merge with --no-ff
Copy the code
  • Using SourceTree operations:

  • In this case, you cangit statusView your workspace and you can create Bug branches;
  • Sure thanksmasterBranch fix Bug:
      Mac-Pro:gitTest kys- 1$ git checkout master
      Switched to branch 'master'
      Your branch is up-to-date with 'origin/master'.
      Mac-Pro:gitTest kys- 1$ git checkout -b bug
      Switched to a new branch 'bug'
      Mac-Pro:gitTest kys- 1$ git add README.md
      Mac-Pro:gitTest kys- 1$ git commit -m "fix bug"
        [bug 2c013d1] fix bug
       1 file changed, 1 insertion(+), 1 deletion(-) Mac-Pro:gitTest kys- 1$ git checkout master
      Switched to branch 'master'
      Your branch is up-to-date with 'origin/master'.
      Mac-Pro:gitTest kys- 1$ git checkout -b bug
      Switched to a new branch 'bug'
      Mac-Pro:gitTest kys- 1$ git add README.md
      Mac-Pro:gitTest kys- 1$ git commit -m "fix bug"
        [bug 2c013d1] fix bug
       1 file changed, 1 insertion(+), 1 deletion(-)
Copy the code

  • inbugAfter fixing bugs on branches and submitting them, you can merge and delete thembugBranches, as follows:
       Mac-Pro:gitTest kys- 1$ git checkout master
        Switched to branch 'master'
        Your branch is up-to-date with 'origin/master'.
        Mac-Pro:gitTest kys- 1$ git merge --no-ff -m "merge bug" bug
        Merge made by the 'recursive' strategy.
       README.md | 2 +-
       1 file changed, 1 insertion(+), 1 deletion(-)
        Mac-Pro:gitTest kys- 1$ git branch -d bug
        Deleted branch bug (was 2c013d1).
Copy the code
  • SourceTree operation:

  • Once the Bug is fixed, we need to take the branch out of the staging area and switch todevBranch, usinggit stash listCommand view:
Mac-Pro:gitTest kys- 1$ git stash list
      stash@{0}: WIP on dev: 40bMerge with --no-ff e6d0 merge with --no-ff e6d0 merge with --no-ff e6d0 merge with --no-ff e6d0 merge with --no-ff The other is to remove the stash content while restoring with 'git Stash pop' : Mac-Pro:gitTest Kys- 1$ git stash pop
        On branch dev
        Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working   directory)

	    modified:   README.md

      no changes added to commit (use "git add" and/or "git commit -a")
Copy the code
  • SourceTree operation:

Feature branch
  • In the development process, each new function needs to be developed, a branch needs to be added, and finally merged and deleted, the process is the same as abovebugThe branches are the same.
  • Delete a branch forcibly. For example, if you develop a new branch and cancel it later, you can only delete all the content in the branch as follows:
      Mac-Pro:gitTest kys- 1$ git branch -d feature
       error: The branch 'feature' is not fully merged.
      If you are sure you want to delete it, run 'git branch -D feature'.
Copy the code

Git branch -d feature

      Mac-Pro:gitTest kys- 1$ git branch -D feature
      Deleted branch feature (was 5f7e86c).
Copy the code
  • SourceTree operation:

Label management
  • Function: The tag serves as a snapshot of the version library, which can be quickly found when needed.
  • Adds a label to the specified submission node. The default label is the latest submission nodegit tagCommand to add labels, usegit showCommand to view label information:
      Mac-Pro:gitTest kys- 1$ git tag V1. 0  / / * * *
      Mac-Pro:gitTest kys- 1$ git tag    / / * * *
        V1. 0
      Mac-Pro:gitTest kys- 1$ git show V1. 0  / / * * *
      commit d0fc2232015ae6737273fa5e94310bcfd4ef231c
      Author:  <40188217@qq.com>
      Date:   Wed Apr 13 07:45:48 2016 +0800

        add a tag

      diff --git a/README.md b/README.md
      index 9082c3c.52.ef851 100644
      --- a/README.md
      +++ b/README.md
      @@ 9 -.4 +9.4 @@ Try a new way!
       Try doing a different thing!
       Try again!
       I am developing!!!
      -
      +I want to make a tag!
Copy the code
  • SourceTree operation:

  • usegit tag -d <tagname>Command to delete a local labelgit push origin <tagname>The command can be used to push a local labelgit push origin --tagsTo push all unpushed local labels, run thegit push origin :refs/tags/<tagname>To delete a remote label, run the following command:
      Mac-Pro:gitTest kys- 1$ git tag -d V1. 0
      Deleted tag 'V1.0' (was 6462641) Push tabs to remote: Mac-Pro:gitTest Kys- 1$ git push origin V1. 0  / / * * *
      Counting objects: 5, done.
      Delta compression using up to 8 threads.
      Compressing objects: 100% (4/4), done.
      Writing objects: 100% (5/5), 497 bytes | 0 bytes/s, done.
      Total 5 (delta 2), reused 0 (delta 0)
      To https://github.com/123sunxiaolin/gitTest.git
       * [new tag]         V1. 0 -> V1. 0Push Locally unpushed labels: Mac-Pro:gitTest Kys- 1$ git push origin --tags  / / * * *
       Counting objects: 1, done.
       Writing objects: 100% (1/1), 154 bytes | 0 bytes/s, done.
       Total 1 (delta 0), reused 0 (delta 0)
      To https://github.com/123sunxiaolin/gitTest.git
       * [new tag]         V01. -> V01.
Copy the code

Delete pushed tags, first, delete local tags, second, delete remote tags:

      Mac-Pro:gitTest kys- 1$ git tag -d V01.  / / * * *
      Deleted tag 'V0.1' (was 98817ff)
      Mac-Pro:gitTest kys- 1$ git push origin :refs/tags/V01.  / / * * *
      To https://github.com/123sunxiaolin/gitTest.git
       - [deleted]         V01.
Copy the code
  • SourceTree operation: Click the label, right click and select DeleteDelete all remote labelsRemote tags can be deleted, the operation is very intuitive:

Ignore special files
  • There are some configuration files in the Git working directory that you don’t want to commit to a remote repository.gitignoreFile;
  • The rule for ignoring files is to ignore files automatically generated by the operating system, such as thumbnails,

Ignore compile-generated intermediate files, executables, etc. Ignore your own configuration files with sensitive information, such as passwords.

  • First, in the Git directory, usegit touch .gitignorecreate. gitignore File, then edit:
      Mac-Pro:gitTest kys- 1$ touch .gitignore
      Mac-Pro:gitTest kys- 1$ ls -ah
      .		.DS_Store	.gitignore
      ..		.git		README.md
Copy the code

  • If you don’t know much about configuration files, take a look at the off-the-shelf configuration list.
  • Common rules:

/ MTK/Filter the entire folder

*.zip filters all. Zip files/MTK /do.c filters a specific file

Gitignore can also specify which files to add to version management, just by adding one in front of the file! You can:

! *.zip

! /mtk/one.txt

Among them,! / MTK /one.txt = / MTK /one.txt = / MTK /one.txt

The only difference is that Git adds an exclamation mark at the beginning of the rule, and files that meet this rule will be added to version management.

  • The last step is to go. gitignore Push the file to the remote repository.
Write in the last
  • In the development process, many people struggle with whether it is better to use Git command or SourceTree client for version management. There is no clear answer, but it is up to you. There are pros and cons to both methods.
  • Write this, finally can breathe a sigh of relief, finally, attach oneself write article screenshots, hope everybody give a point of applause to encourage.

From April 8 began to write, to write today, nearly a week, halfway encountered many problems, fortunately, all adhere to down, do the program ape will have to spell ah, otherwise how can attack the city lion ah!

  • The above content is a simple summary of my common algorithms. If you have any other comments, please feel free to comment.
  • Scan the qr code below, welcome to follow my personal wechat public account: Ape Perspective (ID:iOSDevSkills), you can leave a message on wechat public account, more exciting technical articles, looking forward to your participation! Discuss and grow together! Attack the lion!