Github: add local directory/files to remote repository of Github

Github is a more popular and social code repository. It is the trend to be a user, at least it is true for now.

There are a lot of problems we may meet, most of them can be solved by reading the documentation. But that is not fast or something we like to do.

Problem 1: git commit

A common problem is about committing an existing directory to github. After typing “git commit”, the following message is shown and those files are not shown on gitbub website.

ryan@programcreek:~/Desktop/Design-Patterns$ git commit
# On branch master
# Untracked files:
# (use “git add …” to include in what will be committed)
#
# README~
nothing added to commit but untracked files present (use “git add” to track)

Solution:

In git, a commit is a local operation that doesn’t affect the remote repository. Unlike commit in CVS/SVN, nothing will show up on github after you “git commit”. A push is what sends your commits to the remote repository.

Problem 2: git add an empty directory

After inputting “git add dir_name”, and push to remote repository, the empty directory does not show on github website.

Solution:

The problem is we can not add empty directories to a project. The “add” command works only for files and it will automatically add the directory which the file is in if the directory is not already there.

Leave a Comment