To git@github.com: mintist/JFF-RTOS.git ! [rejected] master -> master (non-fast-forward)error: failed to push some refs to 'git@github.com:mintist/JFF-RTOS.git'To prevent you from losing history, non-fast-forward updates were rejectedMerge the remote changes (e.g. 'git pull') before pushing again. See the'Note about fast-forwards' section of 'git push --help' for details.
If an error occursPullJust a moment ~~
For more information about common updates, see the following. It is available for test ~~~
To sum up the commonly used commands on GitHub in Ubuntu, skip the Settings section. Assume that the repository name is hello-world:
1. Create a New Repository:
Create and write related names and descriptions on GitHub.
$ Cd ~ /Hello-world // go to the hello-World Directory,The local directory name and repository name are not necessarily the same
$ Git init // Initialization
$ Git Add. // Add all files to the index (if you do not want to add all files, you can use gitignore or add a specific file. See the following figure)
$ Git commit // submit it to the local repository, and then fill in the Update log (-M "Update log" is also acceptable, such as $ git commit-M "My first vesion... ")
$ Git remote add origin git@github.com: 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. // automatically determines which files are added, or manually add the file name.
$ Git commit // submit it to the local repository. If no parameter is added, a prompt will be displayed. Note: ^ = ctrl. Just follow the prompts to complete the operation ~~~
$ Git push origin master // not newly created, no need to add it to remote
3. Update the project (only files are deleted or modified without adding new files ):
$ Cd ~ /Hello-world
$ Git commit-A // record which files have been deleted or modified
$ Git push origin master // submit to GitHub
4. Ignore some files, such as *. O:
$ Cd ~ /Hello-world
$ Vim. gitignore // Add the file type to. gitignore and save
Then git add can automatically filter such files.
5. Clone the code locally:
$ Git clone git@github.com: wadeleng/ hello-world.git
If the Code already exists locally and there is an update in the repository, merge the changes to the local project:
$ Git fetch origin // obtain remote updates
$ Git merge origin/Master // merge the updated content to the local branch
6. Undo
$ Git Reset
7. Delete
$ Git RM * // RM is not used
// ------------------------------ Common Errors -----------------------------------
1. $ git remote add origin git@github.com: wadeleng/hello-world.git
Error message: Fatal: remote origin already exists.
Solution: $ git remote RM Origin
Then the error will not be reported when you execute: $ git remote add origin git@github.com: wadeleng/hello-world.git
2. $ git push origin master
Error message: Error: failed to push som refs
Solution: $ git pull origin master // first pull the file above the remote server GitHub and then push it.
//------------------------------------------------------------------------------
A Chinese git Manual: http://progit.org/book/zh/
Http://hi.baidu.com/wade_hit/item/848869db05e53af4cb0c391b