sgc_072

GIT

May 12th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 KB | None | 0 0
  1. Topic: Write an explanation for the three states that a file can have in Git: modified, staged, and committed.Don't assume any knowledge of Git: imagine you are explaining these concepts to a new software developer.
  2.  
  3. Git is a version control system and it can be used to track changes in the files of your project.
  4.  
  5. So, when we are using git, then the files involved can be in three states namely: modified, staged or commited. Firstly, I'll give a brief overview of the git system and then explain, when the files are in the above given states.
  6.  
  7. Git is mainly divided into two areas. One is the 'main server' and other is your 'local machine'. So, while developing your project, you exchange data and information between these two areas. Now, I'll explain you about these two areas.
  8.  
  9. The first area is the 'main server' which in git terminology is called 'GitHub'. So, as the name appears it's a 'hub' where you can store your files. In this 'main server', your files are stored in a main folder, which is called 'repository' and different projects will have different folders or repositories on the GitHub. So, the files on 'GitHub' is independent of any change as long as you 'push' your changes from your local machine to'GitHub'. What is 'push'? We'll discuss it later. As said earlier, 'git track changes', so this repository also contains the information about the changes you did to your files.
  10.  
  11. The second area is the 'local machine' which is the system on which you have the files, you are making changes to. This area is totally under your control. This area is subdivided into three environments namely: Local, Staging Area and Workspace. 'Local Area' is the local copy of your remote git repository, stored on 'GitHub'. This contains the entire history of the changes done to the files on the remote repo along with the local changes. Next comes the 'Staging Area' which basically contains the snapshot of the changes you want to commit. If you want to 'commit' a change, that means you are ready to make that change as part of the main project stored on the 'GitHub'. When you commit, the changes that you commit, move to the 'Local Area' and becomes the part of the repository stored locally on your machine. We are constantly talking about making changes, but where do we actually make those changes i.e modify our files? The changes are made in the third zone known as 'Workspace'. All the changes that we make in the files are made in the workspace. The changes which we think are fine are added to the staging area. When the changes are in the staging area, we commit those files and move those changes to the 'Local Area', where they are ready to be pushed to GitHub. Finally, when we 'push' our committed changes, then our remote repository at 'GitHub' gets updated.
  12.  
  13. So, in all the above processes, our files can have three states, which are modified, staged, or committed. When we modify our files in the workspace, the files are said to be modified with the changes that we made to those files. When the files are added to the staging area, the files are said to be staged. And when those staged files are committed and send to the 'Local Area', then those files are said to be committed. That was all about the three states in which a file can exist in git.
Add Comment
Please, Sign In to add comment