How to push changes to Git Hub using the command line?
Go to the web page for your GitHub repository, and note the URL.
Open Bash on Windows. (If you're using Linux or Mac, open Terminal.)
Use the
cd
command to switch to the directory you want to use to work on your project locally.Enter
git clone [URL of your repository]
to copy your repository to your local machine.Use the
cd
command to go into your repository directory. You'll know you're in the right place if your new command line ends with the name of the main branch of your repository. For example, the name of my main branch is "main," so(main)
appears at the end of my command line.Once you've added your files to your directory and are ready to push to GitHub, in your Bash window, enter
git add .
to select all the files in your repository.Enter
git commit -m "[commit message]"
to save the changes to your local repository. You can enter anything for the commit message, but adding-m "[commit message]"
specifies what this code change is doing, so it's helpful to be clear and concise.Enter
git push origin [branch name]
to save your code changes to GitHub.
If you haven't already done so, GitHub will prompt you to authenticate your identity. Enter your GitHub username and password. Once the authentication is done, the upload process will start. After it's complete, you'll see specific details about where the data was uploaded.
That's it! You've successfully pushed your local files and folders to your GitHub repository.
Comments
Post a Comment