docs/socialserv/2023-03-15-gitflowCheetShee...

191 lines
3.9 KiB
Markdown
Raw Normal View History

---
title: CHEETSHEET DE GIT Y GITFLOW EN
author: Decentralized Climate Foundation
date: 2023-03-15
category: git-flow
layout: post
---
2023-02-20 17:04:55 +00:00
## GIT
---
2023-02-22 17:58:28 +00:00
### Basic or common Git Commands
2023-02-20 17:04:55 +00:00
```shell
2023-02-22 17:58:28 +00:00
$ git init # Create a new git repository
$ git add # Add files to the staging area
$ git status # Check the status of the repository
$ git commit -m # Move files from the staging area to the local repository with a commit message
$ git log # View the file versions in the repository
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git clone # Clone a remote repository
$ git push # Modify the remote repository with your new changes
$ git pull # Update your local repository with the latest changes from the remote
$ git add . # Add all modified files to the staging area
2023-02-20 17:04:55 +00:00
```
---
## GIT FLOW
---
2023-02-22 17:58:28 +00:00
### To install git flow on Debian Linux,
You need to have git installed first. Here are the commands you can execute in your terminal as sudo or root:
2023-02-20 17:04:55 +00:00
```
$ sudo apt-get update
$ sudo apt-get install git-flow
```
2023-02-22 17:58:28 +00:00
### INITIALIZE
Once you're inside your git directory or cloned repository, initialize git flow:
2023-02-20 17:04:55 +00:00
```
$ git flow init
```
2023-02-22 17:58:28 +00:00
### GIT FLOW BRANCHES
2023-02-20 17:04:55 +00:00
![](https://www.campingcoder.com/post/20180412-git-flow.png)
2023-02-22 18:05:11 +00:00
* **Master**: Main branch that maintains the stable version of a software.
* **Develop**: Branch used by one or more programmers for a software in testing mode.
2023-02-22 17:58:28 +00:00
* **Feature**: Temporary or local branch, used for each programmer to develop a specific function (library, function, class, etc.).
* **Release**: Temporary branch only for publishing version tags and synchronizing develop with master. This is done when we have a stable version of software or a milestone for delivery.
* **Hotfix**: Temporary branch used to fix critical errors or bugs in production code, usually used in emergency mode.
2023-02-20 17:04:55 +00:00
#### FEATURES
---
**1. START A FEATURE**
2023-02-20 17:04:55 +00:00
```
$ git flow feature start MYFEATURE
```
2023-02-22 17:58:28 +00:00
> Replace "MYFEATURE" with the name you want to give your feature.
2023-02-20 17:04:55 +00:00
---
2023-02-22 17:58:28 +00:00
**2. FINISH A FEATURE**
2023-02-20 17:04:55 +00:00
```
2023-02-22 17:58:28 +00:00
$ git flow feature finish MYFEATURE # Finish development of a feature.
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ GETTING PUBLISHED FEATURES
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git flow feature pull origin MYFEATURE # Get a feature published by another.
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git flow feature track MYFEATURE # You can keep track of your changes.
2023-02-20 17:04:55 +00:00
```
#### RELEASE
---
2023-02-22 17:58:28 +00:00
**HOW TO PUBLISH A VERSION**
2023-02-20 17:04:55 +00:00
```
$ git checkout master
$ git pull
$ git checkout develop
$ git pull
$ git flow release start 1.0
$ git flow release publish 1.0
$ git flow release finish 1.0
$ git push origin --all --follow-tags
```
---
#### HOTFIX
---
2023-02-22 17:58:28 +00:00
**HOW TO PUBLISH A HOTFIX**
2023-02-20 17:04:55 +00:00
```
$ git checkout develop
$ git pull
$ git checkout master
$ git pull
2023-02-22 17:58:28 +00:00
$ git flow hotfix start (Name)
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
# Make changes
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git status # Check the file in red
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git add . # add files
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
$ git commit -m # 'Write a comment'
2023-02-20 17:04:55 +00:00
$ git flow hotfix finish (name)
2023-02-22 17:58:28 +00:00
# Remember to put a fixed version tag 1.2.x for example 1.2.2
# You were on master, and then you should be on the development branch
2023-02-20 17:04:55 +00:00
$ git push origin --all --follow-tags
```
## LICENSE
```
Copyright (C) 2023 DECENTRALIZED CLIMATE FOUNDATION A.C.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the section entitled "GNU
Free Documentation License".
```
2023-02-22 18:48:25 +00:00
## CONTACT AND DEVELOPERS
2023-02-20 17:04:55 +00:00
> Work developed in collaboration with the [Decentralized Climate Foundation](https://decentralizedclimate.org).
2023-02-22 17:58:28 +00:00
- [Gustavo Bermudez](mailto:nizaries44@gmail.com)
2023-02-22 19:08:57 +00:00
Reviewer:
2023-02-22 17:58:28 +00:00
2023-02-22 18:05:11 +00:00
- [David E. Perez Negron R.](mailto:david@neetsec.com)
2023-02-22 17:58:28 +00:00
2023-02-20 17:04:55 +00:00
2023-02-22 17:58:28 +00:00
## REFERENCES
\[1\] Daniel Kummer, "Git-flow cheatsheet", https://danielkummer.github.io/git-flow-cheatsheet/index.html), 2023.
2023-02-20 17:04:55 +00:00
\[2\] www.campingcoder.com, "How to use git flow", https://www.campingcoder.com/2018/04/how-to-use-git-flow/, 2023.