Solution to Exercise
- Git by default will accept changes in files (new, modified, deleted) as a change but not empty directories
- Empty directory cannot be added to git version by default.
Git Contd
- Staging area can be considered as a draft area where you can add your changes, once you are ok with changes you can commit them or if you are not ok modify further or remove them staging area
- In Git the files that are part of version control i.e. local repo are considered as tracked files.
- We have done two changes
- modify the existing file
- Status: modified
- create the new file
- Status: UnTracked
- modify the existing file
- To add the files to the staging area
- specific path =>
git add <path to file> - modified files =>
git add -u - All the changes =>
git add -A - All the changes w.r.t to current directory
git add .
- specific path =>
- Lets add all the changes
- Lets make some more changes and add to the staging area
- Lets make some more changes in the working tree
- Status:
- Difference:
- Status:
- Lets add all the changes and commit to the local repo
- Lets look at the history
- Lets create a fourth commit where we modify the existing content
- Now lets understand more about diff
- Scenario 1: Working Tree is clean
- Scenario 2: Find difference in two commits
- Scenario 3: Find difference in range of commits
- Lets revisit diff after we understand git configurations
- Scenario 1: Working Tree is clean
- Overview of commands
- Lets try to understand Removing the Changes from staging Area
- Lets add some change to staging area
- Now lets use reset as shown below to move the changes from staging area to workig tree
- Now lets remove the changes from working tree as well
- Lets add some change to staging area
- NOw lets create a change and add to the staging area with modified and untracked changes
- Add changes to staging area
- Move the changes back to Working tree
- To remove the changes from modified file we can use
git checkout - git clean will remove the untracked files from your working tree
- Add changes to staging area
