Git: How to add new files and directories?

If you are working with Git and want to add a new file or directory, follow the following steps

Go to the directory where your file is located.

$ cd directory
$ git add filename

Now you must commit these changes (You can give necessary comments)

$ git commit -m "Adding a new file"

If you want to add a directory, Go to the directory where the directory you want to add is located.

$ cd directory
$ git add directoryname

Now you must commit these changes (You can give necessary comments)

$ git commit -m "Adding a new directory"

Note that the above step will also commit the subdirectories and files present in the directory.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s