Activity: Version Control System on Linux (Using Git)

In this activity, you'll use Git (a version control system) to track changes in files and push your project to GitHub. Follow the steps below to create, modify, and commit changes to a file 10 times and push your code to a remote repository on GitHub.

Step 1: Log in to PythonAnywhere and Open a Bash Console

  1. Go to pythonanywhere.com and log in.

  2. Open a Bash Console from your dashboard.

Step 2: Navigate to the Projects Folder

  • Use the cd command to go to the projects folder you created earlier:
cd projects

Step 3: Initialize Git in the Projects Folder

  1. Initialize Git in your project folder

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

  1. Verify that Git has been initialized by checking the hidden .git folder:
ls -a

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

Step 4: 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:

git commit -m "Initial commit: add project_file.txt"

Step 5: 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:

git commit -m "Commit #1: added Change 1"
  1. Repeat this process 9 more times, modifying the file, adding the changes, and committing them with unique messages:
echo "Change 2" >> project_file.txt
git add project_file.txt
git commit -m "Commit #2: added Change 2"

echo "Change 3" >> project_file.txt
git add project_file.txt
git commit -m "Commit #3: added Change 3"

# Continue this pattern up to Change 10

Step 6: Add a Remote Repository on GitHub

  1. Go to GitHub and create a new repository.

  2. Copy the remote repository URL (from GitHub) and link it to your local repository:

Step 7: Push the Code to GitHub

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

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


Documentation Process

  1. Document your process on Hashnode (similar to previous activities).

    • Title: "Using Git for Version Control on PythonAnywhere"

    • Outline:

      • Initializing Git

      • Making changes to the file and committing 10 times

      • Adding a remote repository and pushing the code to GitHub

    • Include code snippets of the commands you used for easy reference.

    • Share the link to your GitHub repository.

Recap:

  • Initialized a Git repository in the projects folder.

  • Created a file, modified it 10 times, and committed the changes.

  • Added a remote repository on GitHub and pushed your code.

  • Documented the process in hashnode (Please Include repository Link) and share the link on the svfc portal