skills-introduction-to-github

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

2-commit-a-file.md (3197B)


      1 ## Step 2: Commit a file
      2 
      3 _You created a branch! :tada:_
      4 
      5 Creating a branch allows you to edit your project without changing the `main` branch. Now that you have a branch, it’s time to create a file and make your first commit!
      6 
      7 **What is a commit?**: A _[commit](https://docs.github.com/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits)_ is a set of changes to the files and folders in your project. A commit exists in a branch. For more information, see "[About commits](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/about-commits)".
      8 
      9 ### :keyboard: Activity: Your first commit
     10 
     11 The following steps will guide you through the process of committing a change on GitHub. A commit records changes to the project such as adding/removing/renaming files and modifying file content. For this exercise, committing a change will be adding a new file to your new branch.
     12 
     13 > [!NOTE]
     14 > `.md` is a file extension that creates a Markdown file. You can learn more about Markdown by visiting "[Basic writing and formatting syntax](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax)" in our docs or by taking the "[Communicating using Markdown](https://github.com/skills/communicate-using-markdown)" Skills Exercise.
     15 
     16 1. On the **< > Code** tab in the header menu of your repository, make sure you're on your new branch `my-first-branch`.
     17 
     18 2. Select the **Add file** drop-down and click **Create new file**.
     19 
     20    <img width="300" alt="screenshot of the create new file option" src="https://github.com/user-attachments/assets/cfb062cd-be60-4f12-948c-0946a6fe01da">
     21 
     22 3. In the **Name your file...** field, enter `PROFILE.md`.
     23 
     24 4. In the **Enter file contents here** area, copy the following content to your file:
     25 
     26    ```
     27    Welcome to my GitHub profile!
     28    ```
     29 
     30    ![screenshot for adding the profile.md file](https://github.com/user-attachments/assets/e00540be-4334-4d0d-adc2-9893b5477a91)
     31 
     32 5. Click **Commit changes...** in the upper right corner above the contents box. A dialog will appear.
     33 
     34 6. GitHub offers a simple default message, but let's change it slightly for practice. Enter `Add PROFILE.md` in the **Commit message** field.
     35    
     36    - A **commit message** and optional **extended description** help provide clarity for your changes. This is particularly useful when your commit involves several files.
     37 
     38    <img width="400" alt="screenshot of adding a new file with a commit message" src="https://github.com/user-attachments/assets/6ab299ce-8039-4734-a707-d7c3cd7077a0">
     39 
     40 6. In this lesson, we'll ignore the other fields for now and click **Commit changes**.
     41 
     42 7. Now that you've changed a file, Mona should already be busy checking your work. Give her a moment and keep watch in the comments. You will see her respond with progress info and the next lesson.
     43 
     44 
     45 <details>
     46 <summary>Having trouble? 🤷</summary><br/>
     47 
     48 If you don't get feedback, here are some things to check:
     49 - Make sure you are on the `my-first-branch` branch.
     50 - Ensure the `PROFILE.md` file is created and in the root folder.
     51 
     52 </details>