YouTip LogoYouTip

Git Add

# git add Command [![Image 6: Git Basic Operations](#)Git Basic Operations](#) * * * The **git add** command adds file modifications to the staging area. By running the **git add** command, you can tell Git which file changes should be included in the next commit. Add one or more files to the staging area: git add ... Add a specified directory to the staging area, including subdirectories: git add Add all files in the current directory to the staging area: git add . In the following example, we add two files: $ touch README # Create file $ touch hello.php # Create file $ ls README hello.php $ git status -s ?? README ?? hello.php $ !(#) The git status command is used to view the current state of the project. Next, we execute the git add command to add the files: $ git add README hello.php Now, if we execute git status again, we can see that these two files have been added. $ git status -s A README A hello.php $ !(#) In a new project, adding all files is common. We can use the **git add .** command to add all files in the current project. Now, let's modify the README file: $ vim README Add the following content to README: **# Git Test**, then save and exit. Execute git status again: $ git status -s AM README A hello.php !(#) The AM status means that this file has been modified after we added it to the cache. After the modification, we execute the git add . command again to add it to the cache: $ git add . $ git status -s A README A hello.php After modifying a file, we generally need to perform the git add operation to save the historical version. * * Git Basic Operations](#)
← Python3 String IsupperPython3 String Islower β†’