Set Up Name and Email Info
First, you need to setup a default name and email. Else, git won’t let you commit.
Everytime you commit, your user name and email is in part of the commit info. This allows git to show who did what, when working in a team. That’s why user name and email are required. (you can use random name and email if you want)
# set up default name and email git config --global user.name "test" git config --global user.email "firstname.lastname@example.org"
the above will create a file at ~/.gitconfig. You can run these commands again to change. (you can also edit the file directly.)
git Commands for New Project
Create a git repository in current dir. This will create a directory named “.git” in current dir. The “.git” directory holds all git’s internal data.
git clone url
Clone the repository from url_or_path to current dir. “clone” basically means copy. The url can be a local directory/folder path that contains “.git”.
Show current status. (that is, list changed files.)
git add .
Add changes from current dir to local repository’s staging area.
git commit -m "message"
Commit changes after add, to local repository. The message is a short description of changes you made.
Pull from remote to your local repository.
Push your local repository to remote.
Note: all git operations are done to the local repository. The only exception is git pull and git push.