In project development, the synchronization of code is important, and several people in the team can manage their own open source project code through free GitHub, which is efficient and convenient. Here's a list of GIT commands that are often used in development, based on the GitHub platform.
0. Configure the submitter's account and mailbox name
git config--global"Your Real Name" --global User.email [ Email protected] //Email
1 Create the warehouse locally and sync to remote GitHub.
$git init // Initialize $git Add. // add all the 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 (fill in the update log-m, such as $git Commit-M "My first vesion of ...") $git remote add origin [email protected]:wadeleng/hello-world.git
//
added to remote
$git push Origin master
//
push to GitHub
2 Clone a project on GitHub to a local
$git clone [Email protected]:wadeleng/hello-World.git If the code is already in place, and there are updates in the repository, merge the changes into the local project: $git Fetch Origin // get remote update $git merge Origin// merge updated content into local branch
3 Update Project-Create a new file
$git Add. // this will automatically determine which files are added, or manually add the file name $git Commit // submit to the local warehouse, no parameters will prompt, note: ^=ctrl, follow the prompts to be good ~ ~ ~ $git push Origin master // not newly created, no more add to remote.
4 Update Item-no press created, just modified file contents
$CD ~/hello-- a// record which files were deleted or modified $git push Origin Master// Submit to GitHub
5 Ignore some files when uploading
$vim. Gitignore // Add File type to. gitignore, save then git Add. can automatically filter this file
6 Revocation and deletion
$git Reset // undo $git rm // Delete
Remarks Common exception resolution
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.
The local code must be guaranteed to be up-to-date in the remote, otherwise it cannot be submitted and the company Debase every day.
Administration of the branch to be continued, SSH encryption, etc.
Favorite: http://blog.csdn.net/djl4104804/article/details/50778717
Summary of the Project Code management tool git