Add a File to Github Using Git Bash

Add a File to Github Using Git Bash

This post is part of the complete guide on Git and Github

Here is how you can upload a file or a folder to your Github repository using Git Bash.

Before you can start, you need to:

How to Push a File or Folder to Github

To push a folder or to sync a file from your local folder to your remote Github repository:

  1. Move your file to the cloned repository

  2. Open Git Bash

  3. Go to the current directory where you want the cloned directory to be added.

    Input cd and add your folder location. You can add the folder location by dragging the folder to Git bash.

    $ cd '/c/Users/j-c.chouinard/My First Git Project'
    gitbash drag drop

  4. Add the file and stage it for commit

    $ git add 'yourFileName.py

  5. Commit the file to your local repository

    $ git commit -m 'yourFileName.py

  6. Push the changes to Github

    $ git push origin master

    For simplicity, I considered that you have not built work branches and that you commit straight to the master branch.

After all of this, your file will be committed to your Github repository.

Git Push Recap

In the command line, go to the root directory where your local files are. Optionally initialize the local directory (git init). Add the your file changes (git add) and commit your changes (git commit). Finally, push your changes of the local file or repository to GitHub (git push).

Git Cheatsheet

To learn more about Git Commands, check out this Git Cheatsheet.

git config Setup user information
git init Initialize a repository as a Git repository
git clone [url] Clone a local repository from Github
git add [file path] Add file or folder to your commit staging
git commit -m “[message]” Commit staged content
git push [alias] [branch] Push commit to Github

You now know how to push a folder to Github and to upload files to repository using git.

L’article Add a File to Github Using Git Bash est apparu en premier sur JC Chouinard.

SEO

Leave a Reply

Your email address will not be published. Required fields are marked *

Add a File to Github Using Git Bash

Add a File to Github Using Git Bash

This post is part of the complete guide on Git and Github

Here is how you can upload a file or a folder to your Github repository using Git Bash.

Before you can start, you need to:

How to Push a File or Folder to Github

To push a folder or to sync a file from your local folder to your remote Github repository:

  1. Move your file to the cloned repository

  2. Open Git Bash

  3. Go to the current directory where you want the cloned directory to be added.

    Input cd and add your folder location. You can add the folder location by dragging the folder to Git bash.

    $ cd '/c/Users/j-c.chouinard/My First Git Project'
    gitbash drag drop

  4. Add the file and stage it for commit

    $ git add 'yourFileName.py

  5. Commit the file to your local repository

    $ git commit -m 'yourFileName.py

  6. Push the changes to Github

    $ git push origin master

    For simplicity, I considered that you have not built work branches and that you commit straight to the master branch.

After all of this, your file will be committed to your Github repository.

Git Push Recap

In the command line, go to the root directory where your local files are. Optionally initialize the local directory (git init). Add the your file changes (git add) and commit your changes (git commit). Finally, push your changes of the local file or repository to GitHub (git push).

Git Cheatsheet

To learn more about Git Commands, check out this Git Cheatsheet.

git config Setup user information
git init Initialize a repository as a Git repository
git clone [url] Clone a local repository from Github
git add [file path] Add file or folder to your commit staging
git commit -m “[message]” Commit staged content
git push [alias] [branch] Push commit to Github

You now know how to push a folder to Github and to upload files to repository using git.

L’article Add a File to Github Using Git Bash est apparu en premier sur JC Chouinard.

SEO

Leave a Reply

Your email address will not be published. Required fields are marked *