Code has been added to clipboard!

Processes and Stages Involved in Git Saving Files

Git Workflow Cheat Sheet

Git is a very flexible system. The processes happening here are more than just a simple input-output system. Git workflow cheat sheet and its variations can reveal how Git workflow is constructed and often help developers - or anyone interested in Git - gain a better understanding of the processes involved. That can help you answer the question "What is Git?" and "How does Git work?" and is crucial to understand if you plan to work with Git further.

The previous tutorials have covered the basic commands and actions at Git: how to initiate a new repository or to clone an existing one. For the files to be safely placed at the repository, they have to go through three stages. First, they are changed by the user, that is considered a modification. Once the changes are proposed to be committed - that is the staging phase - they are processed further to commit. Only then the changes are finally secured.

There exist a number of processes in Git and developers have summaries, such as Git workflow cheat sheet or Git flow cheat sheet to assist them. In the tutorial below you can find Git workflow cheat sheet that describes the fundamental stages of saving files at Git. The steps are split one by one to make them easier to understand.

Start reading now!

Git Workflow Cheat Sheet: Main Tips

  • Files in Git have several states in which they exist.
  • The files can be of the modified, staged or committed state.
  • The workflow of Git is often explained by summaries also known as Git workflow cheat sheet.

The Life Cycle of Git Files

So far you have learned how to work with Git repositories, whether to start a new one or clone an existing one. During this process, you inevitably work with files editing, deleting and adding new ones. These actions create changes to repositories; however, initializing a repository does not mean that the files have already started being tracked.

You have been using three main commands to work with the files and repositories: init, add and commit. Next thing to learn is that the files in your working directory can be either tracked or untracked.

Tracked files are those that you see in your previous snapshots. They can be modified, unmodified or staged. Files that have been left out of a snapshot are untracked files.

Three Stages of Edited Files

In general, the files you have edited are interpreted as modified in Git because they have changed after your interference. Like you learned in the previous tutorial, you stage the modified files and then commit the changes you have made. This process is constantly repeated as you work with your projects in Git.

Here is a short explanation of what each state means:

  • Modified - the file has been changed, but not yet committed to the database.
  • Staged - a modified file's current version has been proposed by you to commit.
  • Committed - means that the data has been stored in the database.

You will learn more about the specifics of each tracked files state and how to operate them later. For now, it is important to understand the basic concept of Workflow which you can find in Git workflow cheat sheet below.

How Git Works Step by Step

What is Git? How does Git work? Git flow cheat sheet provides a summary of the answers. As you know, working with Git repositories requires several repetitive actions. A list of them making a Git workflow cheat sheet also known as Git flow cheat sheet looks like this:

  • You begin with cloning Git repository as a working copy.
  • By editing or adding files you modify the working copy.
  • You update the working copy by taking over the changes other developers made.
  • You review the changes and decide if and which ones to commit.
  • Commit changes. You check if there are no mistakes and move the changes to the repository by Git commit command.
  • If you notice that something is wrong, you can always correct the last commit and update the changes.

To describe this Git workflow cheat sheet in a more terms-filled manner, it would look like this:

1. You modify or change files in a working tree (also called working directory or area).
2. Select and stage only the files that you want to commit. Those particular changes are added to the index (a technical term for staging area).
3. You commit a snapshot of those changed files and they land to the repository (.git directory or the HEAD)

Git Workflow Cheat Sheet: Summary

  • Three stages are typical to Git files.
  • They can be modified, staged or committed during the process.
  • Git workflow cheat sheet is a summary of the processes included.