Skip to content

How to upload a file using git

Kam Dahlquist edited this page Sep 15, 2015 · 5 revisions
  1. Note that git will only show the files/directories corresponding to the current branch, even though they are all there (unused branches are hidden). To change to a branch the command is:

     git checkout <branch name>
    
  2. On the command line, navigate to the directory that will contain your incoming clone of the repository. Create folders as usual, as needed. (Remember, space characters require an "escape" character, so best not to have any in the names).

  3. Clone the repository (suggest that you make a different clone for every branch you want to work with because of point number 1 above; also note that there is a special clone URL provided on the right-hand part of the GitHub site):

     git clone <URL of repository> <local folder name for repository>
    
  4. Create the file/folder as you normally would on a regular file system. git will not accept an empty folder, so if you create a new folder, you need to put a file in it. (Remember, space characters require an "escape" character, so best not to have any in the names).

  5. Look at what files git has identified as being new/added:

     git status
    
  6. "Stage" the new files for committing:

     git add <file or files to add>
    

    (you can git add a directory, and all files underneath will be added; you can also use wildcards)

  7. Feel free to type git status again to verify that files are staged for commit.

  8. Commit the file(s):

     git commit -m "<commit message>"
    
  9. Typing git status will show that the files are no longer listed, indicating that they are committed (locally).

  10. Send the new commits to the server:

    git push
    
  11. Verify successful push by looking at the website.

Clone this wiki locally