How to Add Files to Git Updated on January 17, 2022 by Christopher Maiorana 2 Minutes, 34 Seconds to Read By now, you should have a good grasp on the basics of Git. In this article, you will learn how to add files to Git. This means you are, in effect, telling Git which files in your project you would like to monitor for changes. Adding files, and modifications to those files, into the “staging” index is one of the most fundamental actions you will take in Git over many years of using it. Configure Your Git UserAdd Files To The Staging IndexChecking the Status of Your Files Note: this article assumes you are using Git on the command line. Thus, all of the commands below will reflect the command line usage. However, the concepts will remain the same even if you are using one of the popular Git graphical interfaces. Configure Your Git User You will first want to make sure that you have added a username to your Git installation. This is done on the local workstation. Otherwise, Git will not know what name and email to sign on your commits. Git keeps great records, and that part of that process involves knowing who is contributing what. git config --global user.name "Joe Example" And you will then do the same for the email address: git config --global user.email [email protected] Alternatively, you can places these values in your Git configuration file. For many users, keeping an up-to-date configuration file makes transferring your data to other workstations much easier and faster. Add Files To The Staging Index You will constantly find yourself adding files to the staging index in Git. You will be both adding new files for tracking and adding modifications to files that are already being tracked. To add a new file for tracking, use the “add” command followed by the name of the file: git add file.txt There will likely be occasions in which you will want to add the full contents of a sub-directory to the staging index. For example, if you wanted to add the full contents of the “assets” directory to the staging index, you can add the directory followed by a forward slash and an asterisk: git add assets/* You can also add the entire contents of your working directory to staging with the “add” command followed by the -A option. git add -A Remember that each time you make modifications to a file you will need to add those changes to the staging index in the same fashion that you added the file itself. If you have already added files to tracking and only want to record modifications without adding new files, you can use the “add” command followed by the . option. git add . Checking the Status of Your Files Often, you will want to check the status of the files in your project. This can tell you which files are being tracked, not tracked, or modified. In order to get this information, you can use the status command: git status Well done, you now know to add files to Git for tracking. Next, learn how to make commits in Git. Share this Article CM Christopher Maiorana Content Writer II Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog. More Articles by Christopher Related Articles How to Host a Static Site with GitHub Pages Publish Your Lovable Created React WebApp to InMotion Hosting Shared Hosting via GitHub How to Publish Your Lovable Created React WebApp to UltraStack ONE for React Git Checkout Command – How To Switch To Branches and Commits How to Create Your Own Git Server Using Git to Publish Files How to Create a New Account with GitHub How to Commit Changes in Git How to Sign Tags and Commits with Git Git Fundamentals Complete Beginner Guide