Home > Article > Development Tools > Explore how to upload a folder to GitHub
If you want to share code or other project-related files, GitHub, an open source code hosting service, is a good choice. GitHub provides distributed source code management and version control capabilities, and you can upload and synchronize your projects to server-resident repositories. In this article, we will explore how to upload a folder to GitHub.
First, you need to log in to github.com and create a repository. If you don't have an account yet, sign up for one and then create a new repository. You can also use an existing repository.
Use the Git command line tool on your local computer. If you haven't installed Git yet, please download and install it here: Git download link.
Open the command line in the local folder.
In Windows, you can use the following shortcut keys to open the command line:
In Mac, you can open the terminal as follows:
Enter the following command at the command line to clone your repository:
git clone https://github.com/你的GitHub用户名/你的存储库.git
After cloning the repository, you can make changes on your local computer.
Copy the folder that needs to be uploaded to GitHub to the cloned repository.
Enter the following command at the command line to add changes to the staging area:
git add ./
This will add the changes you just copied folder and all its contents to the staging area.
Enter the following command at the command line to commit the changes to the repository:
git commit -m "提交信息"
Note that you need to change the "Commit information " Change to a meaningful commit message that describes exactly what you changed.
Enter the following command at the command line to push the changes to GitHub:
git push origin master
Note that the above command will push the changes to the name A branch of master. If you plan to push changes to another branch, change master to the target branch name.
In this article, we learned how to upload a folder to GitHub. You need to create the repository on GitHub, clone the repository using the Git command line tool, copy the folder uploaded to GitHub in a local folder, add the changes to the staging area, commit the changes, and push the changes to GitHub. Remember to pay attention to the command line window messages, which can help you diagnose errors and solve problems.
The above is the detailed content of Explore how to upload a folder to GitHub. For more information, please follow other related articles on the PHP Chinese website!