Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

The introduction

Today, I’m going to share some basic knowledge for programmers: managing code branches

Every time you release your app, you need to tag it. The specific steps are to merge the development branch code into the master, then tag.

I Manage code branches

1.1 Merge branches into trunk and tag them

  1. Switch back to the master branch and merge
Git checkout Master# merge --no-ff to disable Fast forward; Can save your previous branch history. Better view merge history and Branch status.Git merge --no-ff develop#push
git push

Copy the code

Git push origin master –force

  1. Add labels and push them to the remote repository
Add a tag to the current commit Git tag -a v1.0-m'xxx'Git push origin --tagsCopy the code
  1. Checkout Develop switches back to the development branch
git checkout develop

Copy the code

1.2 Update trunk code to branch

Update trunk code to branch

(feature) git checkout master 
(master) git pull 
(master) git checkout feature 
(feature) git merge master

Copy the code

1.3 Other essential tips

  1. Only newly added libraries are installed; updated libraries are ignored
➜  Housekeeper git:(develop) cat ~/bin/knpod
#! /bin/sh

This command only installs newly added libraries, ignoring updated libraries

pod install --verbose --no-repo-update
# this command updates only the specified libraries, ignoring other libraries
#pod update library name --verbose --no-repo-update


Copy the code
  1. Clone from the original warehouse
➜  git clone  url

Copy the code
  1. Create a new branch

Create a new branch and switch to that branch at the same time,

Create a new branch that points to a tag

git checkout -b [branch] [tag]

➜  Housekeeper git:(master) git checkout -b develop
Switched to a new branch 'develop'➜ Housekeeper git: (develop)Copy the code
➜  Housekeeper git:(develop)     git push --set-upstream origin develop
 * [new branch]      develop -> develop
Branch 'develop' set up to track remote branch 'develop' from 'origin'.

Copy the code

see also

Commonly used git script: kunnan.blog.csdn.net/article/det…

For more information and services, please check out # Applets: iOS Reverse, only for you to present valuable information, focusing on mobile technology research field.

Author: iOS backlinks: juejin.cn/post/702103… Source: Rare earth mining copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.