1, (first into the project folder) through the command gitinit this directory into git can manage the warehouse
Git init
2, add the file to the local repository, use the command git add file, add to staging area inside, if the next decimal point ".", meaning to add all the files under the folder
git Add.
3. Use the command git commit to tell git to submit the file to the repository. In quotation marks for submission instructions
Git commit-m ' first commit '
4. Associating to remote libraries
Git remote add origin your repository address
Such as:
git remote add origin [email protected]:/srv/sample.git
If the above steps are incorrectly written:
GIT remote RM origin//Delete origin
git remote add origin [email protected]:yourname/demo.git//re-add Origin
5, get remote library and local synchronization merge (if the remote library is not empty must do this step, or the subsequent commit will fail)
Git pull--rebase Origin master
6. Push the latest changes to the remote repository: Gitpush-u Origin Master
Note: Origin: Remote repository name; Master: Branch
Note: When we first push, with the-u parameter, git associates the local master branch with the remote Master Branch, and we no longer need to add the-u parameter to the push operation.
If something like the following appears:
Username for ' https://github.com ': shiren1118
Password for ' https://[email protected] ':
To Https://github.com/shiren1118/iOS_code_agile.git
! [Rejected] master, master (Non-fast-forward)
Error:failed to push some refs to ' https://github.com/shiren1118/iOS_code_agile.git '
Hint:updates were rejected because the tip of Yourcurrent branch is behind
Hint:its remote counterpart. Merge the remote changes (e.g. ' git pull ')
Hint:before pushing again.
Hint:see the ' Note about Fast-forwards ' "Git push--help ' for details.
Then enter the command: Git push-u origin master–f can fix the problem
If you get the files on a git server from another account on the same host as the GIT server, use the
Gitclone + git repository path, i.e.: gitclone/srv/sample.git/
Source:
73732769
Uploading local files to a remote git server