How to add files?

QuestionsQuestions4 SkillsProYour First Git LabSep, 10 2025
0137

To add files to your Git repository, follow these steps:

  1. Navigate to your repository: Open your terminal and change to your project directory:

    cd /home/labex/project/my-time-machine
    
  2. Create or modify files: You can create a new file or modify an existing one. For example, to create a new file:

    echo "Hello, World!" > hello.txt
    
  3. Add files to the staging area: Use the git add command to stage the file(s) you want to include in your next commit. To add a specific file:

    git add hello.txt
    

    To add all files in the directory:

    git add .
    
  4. Check the status (optional): You can check which files are staged for commit by running:

    git status
    
  5. Commit the changes: Finally, commit the staged files with a message:

    git commit -m "Add hello.txt file"
    

This process will add your files to the repository and save the changes. Let me know if you need further assistance!

0 Comments

no data
Be the first to share your comment!