Git Add and Remove Files: File Operations Explained
Learn how to add, remove, rename, copy, and commit files in Git. These commands help you manage project changes safely and keep your repository clean.

Contents

Git Add File, Git Delete File, and Git Update Operations
Git is a version control system that tracks data and projects and monitors their versions. Basic operations such as adding, deleting, and updating files with Git let you manage projects effectively. git add adds files, git rm deletes files, and git commit updates files. These concepts make project version control easier.
Git Add (Adding a File)
If you want to add one file or all files to the index, you should use it as follows.
git add "dosya.txt"
// dosya.txt is added to the stage / index and made ready for commit
git add dosya.txt dosya2.txt dosya3.txt
// with this syntax, we added our files to the git stage / index.
In the example above, when the command is run, the file is added to the stage. You can think of the stage as an intermediate layer. The information added here waits for the commit operation, and then we can send it to our repository.
If you want to add all files
git add .
// with the trailing dot, we told Git to add all files to the index and made them ready for commit.
Git Commit (Take and Save a Snapshot)
It takes and saves a snapshot of any change you make with Git. Adding a message / note while performing the commit is a very good idea so that you can understand the changes you made after a while.
git commit –m “commit test”
Git Rm (Deleting a File)
When you want to delete a file that has been added, you can use it as follows.
git rm "dosya.txt"
Git Mv (Renaming a File or Folder)
Sometimes we may name files or folders incorrectly for one reason or another. In this case, we can fix it by using the following command.
Git mv eski.txt yeni.txt
Git Cp (Copying a File or Folder)
cp metin.txt yenimetin.txt
- Git clone
- What Are Git Commit, Revert, and Diff and How Are They Used?
- What Is Git, What Is It Used For, and How to Use Git
- On GitHub you can examine the commands in more detail
Share it if it helped


