# Using Git for Version Control on PythonAnywhere

#### **Activity 3**

### **Navigate to the Projects Folder**

Use the cd command to go to the projects folder you created earlier.

```bash
cd projects
```

### **Initialize Git in the Projects Folder**

1. **Initialize Git** in your project folder
    

```bash
git init
```

This will initialize an empty Git repository in the projects folder.

2. Verify that Git has been initialized by checking the hidden .git folder.
    
    ```bash
    ls -a
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1726994946350/69000bcb-fb59-4659-9721-bcf05397c9e4.png align="center")
    

You should see the .git folder listed, indicating Git is active in this directory.

### **Create and Modify a File**

1. Create a new file named project\_file.txt
    
2. Add the file to the Git staging area
    
3. Commit the file to the Git repository
    

```bash
touch project_file.txt
git add project_file.txt
git commit -m "Initial commit: add project_file.txt"
```

### **Modify and Commit the File 10 Times**

Next, you'll make changes to the file and commit each change. Follow this process to commit changes 10 times.

1. Modify the file
    
2. Add the changes to the Git staging area
    
3. Commit the changes
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1727014735009/99808876-65d5-4077-a7aa-293bcf66ffe1.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1727014773509/2fd6cf9d-7616-4f12-a5af-350e50ae5be9.png align="center")

### **Add a Remote Repository on GitHub**

1. **Go to GitHub** and create a new repository.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1727014923472/1ee4ce19-7768-40f4-bad2-d695eef1092b.png align="center")

2. **Copy the remote repository URL** (from GitHub) and link it to your local repository.  
    
    ```bash
    https://github.com/RomelUsigan/Version_Control_System_on_Linux_Using_Git.git
    ```
    

### **Push the Code to GitHub**

1. **Push the local commits** to the remote repository on GitHub.
    

```bash
git push -u origin master
```

**2\. Verify the push** by going to your GitHub repository and checking that all the commits are visible.

```bash
https://github.com/RomelUsigan/Version_Control_System_on_Linux_Using_Git/blame/24d845e38aa535dc00b1c1ead8d83f92a7bc8832/project_file.txt
```
