Git basic commands and GitFlow Workflow

Source: Internet
Author: User
Tags git workflow

Git basic commands and GitFlow Workflow

This article explains some basic team collaboration commands of Git and GitFlow workflow guide.

Git team collaboration commands
  • 1. Open Branch

    Git branch new branch name, for example, under the master branch, a New Development branch: git branch dev
  • 2. Switch to the new branch

    Git checkout branch name, for example, switch to the new dev: git checkout dev under the master Branch
  • 3. Merge the Split Branch and switch Branch to a command

    Git checkout-B new branch name for example, open a new Development Branch and switch to it immediately: git checkout-B dev
  • 4. switch back to the original Branch

    Git checkout original branch name, for example, switch back to mastergit checkout master Note: The current Branch has been modified. If the current branch has not been commit, the switch will fail. You should first commit, but you do not need to push it.
  • 5. merge branches

    Git merge requires that the branch names be merged. For example, if you have just switched back to the master, you need to merge the dev content: git merge dev is recommended in GitLab (or other git systems) create a merge request to merge the branches and review the code.
  • 6. view the local branch list

    Git branch-a contains remotes/origin, which is a remote branch.
  • 7. view the remote branch list

    git branch -r
  • 8. submit a new local branch to the remote server

    Git push origin new branch name, for example, the newly opened dev branch under the master: git push origin dev
  • 9. Delete remote Branch

    Git push origin: Remote branch name, for example, delete the dev branch that has just been submitted to the remote: git push origin: dev
  • 10. delete a local branch

    Git branch name-d For example, delete the new dev branch under the master branch: git branch dev-d Note: if dev changes, push to remote, the merge operation is performed on GitLab (or other git systems). However, if the local master does not have the latest pull code, the deletion will fail. You can use git pull origin master first, or force Delete git branch dev-D.
  • 11. Update branch list information

    git fetch -p
  • 12. TortoiseGit (Turtle git)

    It is undeniable that in windows, this is a good tool. Whether you are a newbie or a heavy user, I think you can try it.
Git workflow guide: Gitflow Workflow

Before you begin, remember that the process should be taken as a guideline rather than an "iron law ". We just want to tell you what we can do. Therefore, you can combine different processes if necessary.

The Gitflow workflow defines a strict Branch Model for project release. Although it is a bit more complex than a function branch workflow, it provides a robust framework for managing large projects.

Gitflow does not use concepts and commands that go beyond the function branch workflow. Instead, it assigns a clear role to different branches and defines how to interact with each other. In addition to using function branches, you can also use their respective branches in preparation, maintenance, and record Publishing. Of course, you can use all the benefits of the function branch workflow: Pull Requests, isolated experimental development and more efficient collaboration.

Work Mode

The Gitflow workflow still uses the central repository as the Interaction Center for all developers. Like other workflows, developers work locally and push branches to the central repository.

Historical Branch

Compared with the only master branch, Gitflow uses two branches to record the history of the project. The master branch stores the official release history, and the develop branch serves as the integrated branch of the function. In this way, a version number is assigned for all submissions on the master branch.

The remaining issues that need to be explained are centered on the differences between the two branches.

Function Branch

Each new feature is located in its own branch, which can be pushed to the central repository for backup and collaboration. However, the function branch does not pull a new branch from the master branch, but uses the develop branch as the parent branch. When the new function is complete, it is merged back to the develop branch. New Function submission should never directly interact with the master branch.

Note: In terms of meaning and purpose, the function Branch plus the develop branch is the usage of the function branch workflow. However, Gitflow does not stop here.

Release Branch

Once the develop branch has enough functions to make a release (or the desired release date is approaching), it will fork a production branch from the develop branch. The new branch is used to start the release cycle, therefore, new functions cannot be added to this branch after this time point-this branch should only be used for Bug fixing, document generation, and other release-oriented tasks. Once the external release is completed, the Production Branch is merged into the master branch and assigned a version number to Tag it. In addition, the changes made since the new production branch are merged back to the develop branch.

The use of a dedicated branch for release preparation allows a team to complete the current release version while the other team can continue to develop the features of the next version.
This also creates a well-defined development stage (for example, you can easily say, "We have to prepare to release version 4.0 this week", and we can see it in the directory structure of the repository ).

GitHub Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Share practical GitHub tutorials

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.