1. Create a new repository:
Create and write the relevant name and description on GitHub first.
$CD ~/hello-world//to Hello-world directory
$git Init//initialization
$git Add. Add all files to the index (do not want to add all the files, you can use Gitignore or add specific files)
$git Commit//Submit to the local warehouse, and then fill in the Update log (-M "Update log" can also)
$git remote Add origin [email protected]:wadeleng/hello-world.git//Add to Remote
$git Push Origin master//push to GitHub
2. Update the project (new file added):
$CD ~/hello-world
$git Add. This will automatically determine which files are added, or manually add the file name
$git Commit//submit to local warehouse
$git Push Origin master//not newly created, no more add to remote
3. Update the project (no new files, only delete or modify the file):
$CD ~/hello-world
$git commit-a//record which files were deleted or modified
$git Push Origin master//submit to GitHub
4. Ignore some files, such as *.O, etc.:
$CD ~/hello-world
$vim. Gitignore//Add the file type to the. Gitignore, save
Then you can git Add. can automatically filter this file
5.clone code to Local:
$git Clone [Email protected]:wadeleng/hello-world.git
If the code exists locally, and the repository has updates, merge the changes into the local project:
$git fetch origin//Get remote Updates
$git Merge Origin/master//merge updated content into local branch
6. Revocation
$git Reset
7. Delete
$git RM *//Not in RM
------------------------------Common Errors-----------------------------------
1.$ git remote add origin [email protected]:wadeleng/hello-world.git
Error Tip: Fatal:remote origin already exists.
WORKAROUND: $ git Remote RM origin
Then execute: Git remote add origin [email protected]:wadeleng/hello-world.git will not report an error
2. $ Git push origin master
error Hint: error:failed to push som refs to
Workaround: Git pull Origin master//put the file above github on the remote server first, then push it up.
Create git code under Linux