Version Control
Git: Getting started
Git: Getting started
  • Introduction
    • What is version control
      • Distributed VCS
      • Summary
    • What is Git?
      • A Short History of Git
      • Under the hood
      • The Three States
    • What is GitHub?
  • Setting up Git
    • Installation
    • First time setup
    • Creating a repo
  • Basic operations
    • Recording Changes
      • Add another file
      • Modify-stage-commit
      • Modify-direct commit
      • View log
    • Undo changes
      • Restore (modified)
      • Restore (staged)
      • Amend (rare)
    • Clone repos
  • Remote Repos
    • Configure remote
    • Push to remote
      • Push branches
  • Reference
    • My Git Tutorials
    • Git Official
    • Others
Powered by GitBook
On this page
  • Repeat the process with another new file
  • Create a new file
  • Commit the new file
  1. Basic operations
  2. Recording Changes

Add another file

Repeat the process with another new file

Create a new file

Let us create a file called second.txt with one line in it, in the same directory as before and check the status now:

C:\...\GitExperiments\FirstDemo> ls


    Directory:
    C:\Users\ravi_\Source\repos\Experiments\GitExperiments\FirstDemo


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----   Sat  04-02-2023  10:38 AM              6 hello.txt
-a----   Sat  04-02-2023  11:46 AM             10 second.txt
C:\...\GitExperiments\FirstDemo> git status

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        second.txt

nothing added to commit but untracked files present (use "git add" to track)

We can see that Git only shows the untracked files and nothing about the committed files!

Commit the new file

We can add all (untracked) files in one shot and then commit as follows

git add .
git commit -m "second file added"
[master 299930d] second file added
 1 file changed, 1 insertion(+)
 create mode 100644 second.txt
git status
On branch master
nothing to commit, working tree clean
PreviousRecording ChangesNextModify-stage-commit

Last updated 2 years ago