Git Code Submission Process and Git Command Summary (Foundation)

Time:2019-8-13

Basic understanding

The git command is a collection of command-line tools that can be used to track and record changes in files. For example, you can save, compare, analyze, merge and so on. This process is called version control. There are already a series of version control systems, such as SVN, Mercurial, Perforce, CVS, Bitkeep and so on.

Git is distributed, which means that it does not depend on the central server. Any machine can have a local version of the control system, which we call warehouse. If it’s multi-person collaboration, you need an online warehouse to synchronize information. That’s what GitHub, BitBucket does.

I’ve been using Git for a while, and as more and more projects grow, functional branches also increase. From simple basic commands to arbitrary, I need to constantly try to summarize. Here’s a summary of my Git usage.

This chapter focuses on the Git code submission process and the use of Git basic commands.

I. Branch Management of Git Version

Following is a more basic demonstration of branch management. Each company has different project management operations, and branch management has its own characteristics, but it can never be separated from its original purpose.

1) dev branch for daily development

2) When a new version needs to be released, merge dev code into release branch for integration testing and wait for release

3) release branch enters bug repair phase

4) If a bug is found in the release branch, modify it in the release branch and merge the bug-fixing commit into the release branch using git cherry-pick

(cherry-pick, unlike merge, is merged in commit instead of the whole branch)

After completion, all code changes (except version number) on the release branch should have been incorporated into the dev branch.

5) Publish to the online environment after release branch testing is completed

6) and tag it and merge it into the master branch

7) If there is a bug online, hot fix on master

8) After hot fix appears and is repaired, it is necessary to merge hot fix code into Dev and release branches to keep the code consistent.

II. Git Basic Command Pool

Summary of Git Basic Commands

1. View the status of local files

Git status — View file modification status for local, local warehouses, and caches

File modification in red for local workspace

Blue represents the files submitted to the local warehouse (git add.)

2. Switching Version/Overwriting Current Modified Files

Git branch – View the current version

Git branch – a view all versions

Git checkout XXX (version name) – Switch to XXX version in remote library

Git checkout filepath — Overrides the currently modified file

Git checkout. – Overwrite all current modified files

3. Get the latest code from the remote library

Git remote – View remote library name

git remote -v  

Git remote show XXX (remote library name)

Git fetch – pull the latest code from the remote side

Git pull XXX (remote library name) XXX (branch name) – Merge the latest pull code with the current workspace

Git rebase – Pull back code remotely and merge it locally

4. Caching local code

When switching to another version, you want to save the files that are modified in the current version: Do it before switching

Git stash – Cache files that have been modified locally and do not need to be submitted

Git checkout XXX (version) – Switch library version

Cut back to the original library and take the files out of the stash cache

Git stash pop – pull out of the cache

5. Submitting remote Libraries

git add .

git commit -m ”

Git remote view remote association name

The name of GIT push remote is local master

6. Conflict management

Git fetch pulls up the latest project

Git pull XXX (remote library name) XXX (branch name) – Merge the latest pull code with the current workspace

After the conflict occurs, the new code === the old code <<, retains the final code, deletes the prompt, and resubmits.

7. Submit this submission to other branches (e.g. bug modification at publication time)

git cherry-pick commitId

8. Suggested sequence of implementation

Git status view modification status

Git checkout filename discards modifications to a file.

Git stash storage modification

Git fetch pulls up the latest project

Git rebase merges with local branches

Git stash pop pops up to store files, at which point new files may conflict with your files and resolve conflicts.

Git add filename to add a modified file

Git add. Submit all add points

Git reset HEAD filename rolls back the specified file and all additions: “git reset HEAD…”

git commit -m”

Git push local remote branch name, local branch name

For example, my local branch is master remote alias origin and submitted as git push origin master

9. Switching HEAD

Git reflog — View HEAD records

Git reset — hard HEAD ^ // switch to the previous HEAD

Git reset — hard fad4462 // / Switch to a backed HEAD

10. Delete local branch

git branch -d <branch_name>

summary

The above is the Git code submission process and the summary of GIT commands introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave a message for me, and the editor will reply to you in time. Thank you very much for your support to developpaer.

Recommended Today

Write the correct posture of chameleon cross-end components (Part I)

In the chameleon project, there are two ways to implement a cross-end component: using third-party component encapsulation and unified implementation based on chameleon grammar. This article is the first in a series of articles on the correct posture of chameleon cross-end components. Taking encapsulating a cross-end indexList component as an example, it first introduces how […]