GIT

Add File in Git Repository

If you want to add file in Git Repository you can use git add command to add a new file or files to local git repository. Please note ignored file will not be added by default. You can add the single file or multiple fine using git add command.

In GitHub, files that you are adding to a repository using browser are limited to 25 MB per file. If you want to add large files via browser you can add up to 100 MB bias the command line.

Now follow the below process to adding fine in git repository.

Add file in a Git Repository

Run the below command to add the file in git repository. This is actually a multi-step process. First you’ll need to add all your files to the current stage.

# git add .

Note (.) means you are adding all changes/created file in git repository. If you want to single or multiple fine run below command.

Single File:

# git add {filename}

Multiple File:

# git add {filename1} {filename2} {filename3}

Dry run command for git adding will actually not add the file. If you want to test files if they exist and/or will be ignored with git command.

git add . --dry-run

Check Added File Status

You can verify that your files will be added when you commit by checking the status of the current stage.

# git status

You will get the output that lists all of the files that are currently staged, like below:

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached ..." to unstage)
#
#   new file:   README
#   new file:   src/somefile.js
#

If all looks good, then you are ready to commit. Note that the commit action only commits to your local repository.

git commit -m "Type your commit msg here"

If you are not connected your local repository to a remote one yet, you’ll have to do that now. Suppose your remote repository is hosted on GitHub and named “your project name”, your command is going to look something like this:

# git remote add origin [email protected]:username/your-project-name

Once you’re ready to push your commits to the remote repository (origin), you’ll need to use the ‘push’ command:

# git push origin master

 

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at Look Linux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment