How to push changes to Git Hub using the command line?

  1. Go to the web page for your GitHub repository, and note the URL. 

    Example of where to find the URL for a GitHub repository.

  2. Open Bash on Windows. (If you're using Linux or Mac, open Terminal.) 

  3. Use the cd command to switch to the directory you want to use to work on your project locally.

    Cd command in GitHub.

  4. Enter git clone [URL of your repository] to copy your repository to your local machine.

    Code entered in GitHub to copy the GitHub repository to a local machine.

  5. 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.

    GitHub repository directory.

  6. 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. 

  7. 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.

    How to save changes to a local repository.

  8. Enter git push origin [branch name] to save your code changes to GitHub.

    How to save 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

Popular posts from this blog

What are compatibility tests and how are they performed?

What Is a Use Case, Purpose of Use Case and How to Write Use Case?

How to log a bug with a detailed description ?