This will be my first git use. I have added new files ( a lot ) to the folder/project ( git local repository).
I went through online tutorials and forums and see i can do
git commit -a
So i go to the base folder of the repository and do a
sudo git commit -a
But then, some screens comes up and asks me to add a comment which i do. i do not know how to proceed or exit. I do not want to mess up so i did ctrl + Z and did not do anything.
Can you guys please outline the commands i need to use?
git commit -a
and
git push?
Use the
git add
command, followed by a list of space-separated file names, e.g.You can also select multiple files like this
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 stage and commit all your files on Github do the following;
git add -A
git commit -m "commit message"
git push origin master
When you change files or add a new ones in repository you first must stage them.
or if you want to stage all
By doing this you are telling to git what files you want in your next commit. Then you do:
You use
where origin is the remote repository branch and master is your local repository branch.
To add all the changes you've made:
git add .
To commit them:
git commit -m "MY MESSAGE HERE"
#-m is the message flagYou 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.
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.Beware not to put spaces between the
,
.