Revise Homework in Git Hub

Reference - Make changes to all files

  • Open File Explorer to find the project so you can see where the project files are located

  • Open Git Bash - navigate to the desired directory using the cd command. Use quotes or escaping for names of files with spaces. Example: cd c: and then cd "100Dev Classes"

  • In Git Bash: To stage all modified files, as in this example, next type: git add . If you want to make a change to one file, you would have typed

  • git add <file-name> (no <> I think)

  • In Git Bash: Commit the changes by typing: git commit -m "description of changes" Type the quotes for the description, then hit Enter

  • In Git Bash type: git remote add origin <repository-url> (actual w/o <>) Find <repository-url> by going to the repository you want to find the URL for. On the repository's main page, you'll see a green "Code" button on the right side. Click on it and a drop-down menu will appear with the options for cloning the repository. Make sure the "HTTPS" option is selected. Click on the clipboard icon to copy the repository URL to your clipboard. The copied URL is the repository URL you need for cloning or setting up the remote repository in Git. It typically starts with 'github.com/' and includes your username or organization name followed by the repository name.

  • After doing this, I got an error: remote origin already exists. So what I will do is go to the next step to see if it commits correctly.

  • Use the following command in Git Bash to put your committed changes to GitHub:

  • git push -u main (has not worked, had to use git push -u origin main instead and it worked)

  • Go to Settings, Pages, and click on Visit Site at the top of the page.

  • It worked!! Possibly, the error step I did was not necessary. I'll adjust in the future and update these instructions.

Problem: A mix-up in the repository URLS or configurations. If Git is trying to reference a repository URL that doesn't exist. To see where it is pulling from, in Git Bash type git remote -v Make sure the URL listed under "origin" is correct and points to the correct GitHub repository. (In my error, sure enough, it was pointing to a repository that I had deleted since I didn't need it. Not sure why it defaulted to the folder that it did. The following is what I did to redirect it.)

To change where it is if the URL is incorrect: type command git remote set-url origin github.com/your-username/your-repo-name.git

To ensure you are on the correct branch, verify the current branch by typing command git branch

Before attempting anything further, check current status of repository by typing command git status

Then I was good to go, but I got the message: On branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean

Then push the commit to the remote repository on GitHub by typing the command: git push origin main and my problem was fixed.

To only change the index file (staging area), for example:

Make the changes/save the file. Then add the changes to the staging area using this command: git add path/to/your/index/file.html ex: git add "/c/100Dev Classes/Freelancing/Client Sites/Sewing/index.html"

Next commit the changes: git commit -m "Update index file"

Then git push

That worked.