Git Commands

Create a repo

git init

Add changes into index

E.g. Add all the changes under current directory

git add .

Add a particular file

git add ./path/to/your/file/MyClass.java

Check repo status

git status

Commit changes

git commit -m "<the commit message>"

Push changes

git push

 

Add existing repo to Git server

Step 1, add origin to remote

git remote add origin <repo-git-url>

Step 2, push origin as up stream to master branch

git push -u origin master

 


Help

Git help

git help

List available subcommands and some concept guides

git help -a
git help -g

Command help

git <command> --help
git help <command>

E.g.

git add --help

 

Leave a comment