Git files lifecycle

Bogdan Stashchuk
A free video tutorial from Bogdan Stashchuk
Software Engineer, CCIE #22608, MBA, PhD - stashchuk.com
4.6 instructor rating • 14 courses • 150,472 students

Lecture description

Every file has its own lifecycle and there are several possible locations where files could be stored in Git. File could be located in the working directory, staging area or repository.

Learn more from the full course

Complete Git Guide: Understand and master Git and GitHub

Complete Git and GitHub guide. Master basic and advanced Git features: commits, branches, merging, rebasing, squashing.

21:49:57 of on-demand video • Updated September 2020

  • Deeply understand how Git works under the hood
  • Use Git not just in terminal but also in graphical user interfaces like GitHub Desktop, SourceTree, Visual Studio Code
  • Learn different GIt objects - blobs, trees, commits and annotated tags
  • Create local and remote Git repositories
  • Perform basic and advanced Git operations
  • Learn how to perform rebasing and merging of the branches
  • Learn what is pull request and how to create pull request at GitHub
  • Contribute to public repositories using technique of forks and pull requests from the forked repository
  • Understand what is semantic versioning and how to use Git Tags in order to create software release versions
  • Learn advanced Git operations - squashing, cherry-picking, amending, reverting commits.
English [Auto] We have just created the new file in working directory. File three to dig deep and in a console with good stead US command. We see that this file is entourage and in order to start striking it we should use get at come in and it means that when you add any new files into working directory of those files will become automatically entourage and you decide whales or you want to drag them or not. And no less discuss different breaking statuses for every file and life cycle actually of every file. Please note that every file and get may change its status multiple times but by default. When you create new file instead status will be direct. There was no static scoped direct but the deal trusted as a scold. Modify it staged and unmodified and we can say that file is strict when it is IIs or modify it staged or on a modified and let's not discuss different commands and actions that allow you to transition file from one state to another. At first transition is between entourage and stage state and in order to move file from Entourage stage to stage state you should use get at command. And with this command you actually start tracking and you will file and this file is copied from working directory into a staging area. This what you do is get at command and that's why here in the council used this suggestion to use get at command to start to rank and file again that is relevant only to new files that are on tracked okay. Next when file is already staged it is considered as direct. We can compete this file and in order to commit to file you should use get complete command. Of course you usually commit multiple files and folders using single you'd commit command because commit is just a rapper around the 3 object and 3 object may contain links to multiple sub 3s or blobs okay. And when you enter a get commit command and when there are files or file in staged area those files after comedian will transition to a modified state and if you will look at our current distribution of the files among different areas we can say that file Wanda Deeks D and file to the extent are now on modified date are present in all those areas recording directory staging area and the repository. And that's why you file go to time and lo and type did Ellis files this s you'll see those files here in staging area but we don't see any information about those files when we enter status command. Those files are absent in this information book and does because those two files are on modified date. We are not changed since last commit okay. Get commit. Command transitions. State of the file from stage to unmodified and the most cases most files will have unmodified state okay. But what happens if you change specific file in walking directory. What does it mean. For example there are already files file one to dig deep and file to the disks that are currently unmodified and I change for example file to the 60 in working directory and if I make any changes to the file that is already direct that is for example unmodified it will transition estate to modified and you will see those changes with youth status command and in case of when we will modify any of unmodified files for example file one to dig deep or file to the extreme. You'll see here in status output separate section modified files and least of modified files. No worries we will try that soon okay. That's what happens when you make any changes in any unmodified file. It will transition to modified state and when the file is modified you can again use get at command and move this file into staging area. Stage it and when you will stage it its status will transition from modify it to staged it means that the scope of get at command. You can stage IIs or entourage files or modified files and finally you can on track files if a specific file was already committed. You can track this file and move it from unmodified state to entourage state but you might ask me When do we need to undo X specific file or files. This may happen for example when you have added a certain file or files to your repository by mistake and you have already committed those changes and you could remove those files from your repository and make them again entourage more than that. You can even ignore specific files or even folders and if you'll ignore them you will not even see them as entourage files here gets that lost output. We will talk about that later on in the course. For now let's proceed and I know there was a file filed three to the extreme located in working directory but now it is entourage and we should use it at command in order to change its titles from Entourage to staged and do that in the next lecture. But before moving on let me quickly summarize what we discussed in this lecture. There are four states in file life cycle indeed entourage modified staged and unmodified. When you add new file into working directory you it becomes entourage. If you want to stage file or files you should use get at command and you could stage eyes on Entourage files or modified files when there are files in staging area and you can meet changes all those files or file that well located in staging area and well staged move to unmodified state and when the file is unmodified it will be listed in output of goods depots command and that's why here we don't see any information about file one of the 60 and file to the disks. They are now on modified okay. If you change any file that is unmodified it will transition to modified and modified files will be listed in separate section here in this output of status and finally you can on track on modified files some of those operations one file with changes in state level let's say opposite operation what do you mean. For example when file was modified and you have moved it to stage the state with commit to get at. You can onstage this file and move it back to modified state and same for Entourage files well specific file was staged and before it was entourage you can on stage it and make a game on track. But I didn't want to order complicate this diagram. That's why I didn't add to those transitions here and actually they are used not so often. Okay let's go on next. Let's use it at command in order to stage this entourage file. I'll see you next by.