π Code Sharing and Management with GitHub
π₯οΈ For Windows:
-
Launch your preferred web browser.
-
Visit GitHub.
-
In this class, we will be sharing code using repositories on GitHub.
-
Click on the "New" button to create a new repository.
-
Give the new repository the name
W3-Schools-Day-1. -
Enable the "Add a README file" option by selecting "Add README".
-
Click on the "Create repository" button.
-
Now that the remote repository is created, we need to clone it to our local machine to make changes.
-
Click on the "Code" button and select the "HTTPS" option to copy the repository URL.
-
(If you havent instlled git bash alredy) Once the repository is created, you can download and install Git for Windows by visiting Git for Windows and following the installation instructions.
-
After Git is installed, you can open "Git Bash" from the Start menu. This will provide you with a terminal-like interface where you can execute Git commands.
-
In the Git Bash terminal, use the cd command to navigate to the directory where you want to locate the repository. For example:
-
π Use the
cdcommand to navigate to the directory where you want to locate the repository. For example:cd Desktop -
π Use the
git clonecommand followed by the copied URL from GitHub to clone the repository to your machine. For example:git clone <url>
-
π The
git clonecommand creates a new directory with the same name as the repository. Usecdto navigate into the new directory. For example:cd W3-Schools-Day-1 -
π Use the
touchcommand to add files to your local repository as required by the W3 Schools assignment.touch index.html touch style.css touch script.js
-
π Use
git add -Ato add all the changes to your repository.git add -A
-
π To commit your changes, use
git commit -mfollowed by a commit message. For example:git commit -m "Add initial files" -
π Use
git push origin mainto push your changes back to the GitHub repository.git push origin main
-
π It is important to keep your local repository up-to-date. To pull down any changes from the GitHub repository and update your local repository, use
git pull origin main. The "origin" refers to the cloned repository, and "main" is the default branch.git pull origin main
-
π For Mac:
-
Launch your preferred web browser.
-
Visit GitHub.
-
In this class, we will be sharing code using repositories on GitHub.
-
Click on the "New" button to create a new repository.
-
Give the new repository the name
W3-Schools-Day-1. -
Enable the "Add a README file" option by selecting "Add README".
-
Click on the "Create repository" button.
-
Now that the remote repository is created, we need to clone it to our local machine to make changes.
-
Click on the "Code" button and select the "HTTPS" option to copy the repository URL.
-
Open the terminal on your Mac.
-
π Use the
cdcommand to navigate to the directory where you want to locate the repository. For example:cd Desktop -
π Use the
git clonecommand followed by the copied URL from GitHub to clone the repository to your machine. For example:git clone <url>
-
π The
git clonecommand creates a new directory with the same name as the repository. Usecdto navigate into the new directory. For example:cd W3-Schools-Day-1 -
π Use the
touchcommand to add files to your local repository as required by the W3 Schools assignment.touch index.html touch style.css touch script.js
-
π Use
git add -Ato add all the changes to your repository.git add -A
-
π To commit your changes, use
git commit -mfollowed by a commit message. For example:git commit -m "Add initial files" -
π Use
git push origin mainto push your changes back to the GitHub repository.git push origin main
-
π It is important to keep your local repository up-to-date. To pull down any changes from the GitHub repository and update your local repository, use
git pull origin main. The "origin" refers to the cloned repository, and "main" is the default branch.git pull origin main
-
Thanks Abul. This was VERY helpful!
-- John A.