Module 2: Git Assignment - 1

Tasks To Be Performed:

  1. Based on what you have learnt in the class, do the following steps: a. Create a new folder b. Put the following files in the folder
    • Code.txt
    • Log.txt
    • Output.txt
    c. Stage the Code.txt and Output.txt files d. Commit them e. And finally push them to GitHub
  2. Please share the commands for the above points
  1. I create a new folder:
mkdir GitAssignment
  1. I navigate to the new folder:
cd GitAssignment
  1. I create the required files in this folder:
touch Code.txt Log.txt Output.txt
  1. I initialize a new Git repository in this folder:
git init
  1. I stage Code.txt and Output.txt for the commit:
git add Code.txt Output.txt
  1. I commit the staged files with a message:
git commit -m "I added Code.txt and Output.txt files"
  1. I have already set up the remote repository:
  • I’ve previously created a repository on GitHub named GitAssignment.
  • I’ve also configured SSH, enabling me to clone and push to the repository without entering my credentials each time.
  1. I link my local repository to the remote GitHub repository:
git remote add origin git@github.com:hectorproko/GitAssignment.git
  1. I rename the default branch to main:
git branch -M main

GitHub repository’s default branch is already named main

  1. I push my commit to the remote GitHub repository:
git push -u origin main

Success

Now, I’ve successfully added my files to the GitHub repository.