You can add all the files using the git add command like below for all the files you want to add, which will add all your files to the staging area, which means the files are ready to be committed. Now commit your files, the editions or addition made in the files will now be saved.
You can click the “Upload files” button in the toolbar at the top of the file tree. Or, you can drag and drop files from your desktop onto the file tree. Once you've added all the files you want to upload, you can commit them directly to your default branch or create a new branch and open a pull request.
The easiest way to add all files to your Git repository is to use the “git add” command followed by the “-A” option for “all”. In this case, the new (or untracked), deleted and modified files will be added to your Git staging area. We also say that they will be staged.
Use the git add
command, followed by a list of space-separated filenames. Include paths if in other directories, e.g. directory-name/file-name
.
git add file-1 file-2 file-3
To add all the changes you've made:
git add .
To commit them:
git commit -m "MY MESSAGE HERE"
#-m is the message flag
You can put those steps together like this:
git commit -a -m "MY MESSAGE HERE"
To push your committed changes from your local repository to your remote repository:
git push origin master
You might have to type in your username/password for github after this. Here's a good primer on using git. A bit old, but it covers what's going on really well.
As some have mentioned a possible way is using git interactive staging. This is great when you have files with different extensions
$ git add -i
staged unstaged path
1: unchanged +0/-1 TODO
2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
*** Commands ***
1: status 2: update 3: revert 4: add untracked
5: patch 6: diff 7: quit 8: help
What now>
If you press 2
then enter
you will get a list of available files to be added:
What now> 2
staged unstaged path
1: unchanged +0/-1 TODO
2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
Update>>
Now you just have to insert the number of the files you want to add, so if we wanted to add TODO
and index.html
we would type 1,2
Update>> 1,2
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
3: unchanged +5/-1 lib/simplegit.rb
Update>>
You see the *
before the number? that means that the file was added.
Now imagine that you have 7 files and you want to add them all except the 7th? Sure we could type 1,2,3,4,5,6
but imagine instead of 7 we have 16, that would be quite cumbersome, the good thing we don't need to type them all because we can use ranges,by typing 1-6
Update>> 1-6
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
* 4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
7: unchanged +5/-1 file7.html
Update>>
We can even use multiple ranges, so if we want from 1 to 3 and from 5 to 7 we type 1-3, 5-7
:
Update>> 1-3, 5-7
staged unstaged path
* 1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
* 7: unchanged +5/-1 file7.html
Update>>
We can also use this to unstage files, if we type -number
, so if we wanted to unstage file number 1 we would type -1
:
Update>> -1
staged unstaged path
1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
* 5: unchanged +5/-1 file5.html
* 6: unchanged +5/-1 file6.html
* 7: unchanged +5/-1 file7.html
Update>>
And as you can imagine we can also unstage a range of files, so if we type -range
all the files on that range would be unstaged. If we wanted to unstage all the files from 5 to 7 we would type -5-7
:
Update>> -5-7
staged unstaged path
1: unchanged +0/-1 TODO
* 2: unchanged +1/-1 index.html
* 3: unchanged +5/-1 lib/simplegit.rb
4: unchanged +5/-1 file4.html
5: unchanged +5/-1 file5.html
6: unchanged +5/-1 file6.html
7: unchanged +5/-1 file7.html
Update>>
You can also select multiple files like this
git add folder/subfolder/*
This will add all the files in the specified subfolder. Very useful when you edit a bunch of files but you just want to commit some of them...
If you want to add multiple files in a given folder you can split them using {,}
. This is awesome for not repeating long paths, e.g.
git add long/path/{file1,file2,...,filen}
Beware not to put spaces between the ,
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With