So far we have covered how to work with $ git add and $ git commit commands.
$ git status is the command that will tell you
- what branch you are on
- what files you have changed
- what files are not tracked
- hint on what you do next
You can see that it shows you are now on the master branch. Normally it is the default branch. I will explain in a further lesson about what is a branching, merging and forking. Your project is called the working directory when you initial Git to version control your code. You can consider it as the repository. 'Working directory clean' statement tells you that there are no tracked and modified files.
Now we will modify the file1 and check what the $ git status command tells us.
Here git status command tracked the modified files in your repository. That is why it mark in red. So it means that Git is tracking your files and check whether there are any modifications of your files. And it says what you can do next (no changes added to commit (use "git add " and/or "git commit" -a)).
Go ahead and make a new file to check what the $ git status command says.
The reason why because we are not adding this new file to Repository yet. We have only told to Git to be tracked this file. Simply using the $ git add . command or $ git add file2 you can add any untracked files to your Git repository.
Now you will notice that both
modified: file1
new file: file2
are added to the staging area by Git. You can decide it by their green colour.
If you want to remove your files from your repository use $ git rm --cached <filename> command. Because we still don't commit them. Modified and new files are still in the staging area.
Once you check the Git status, you can see that the file2 is untracked again. Then type $ git commit and keep a message of what you have done so far.
This tells you only file1 is committed. If you want to add the file2 you can add it to Git and finally commit it.
0 comments:
Post a Comment