git project and submit a branch operation command

Native code submitted to a remote repository:

Set git user name, e-mail

git config --global user.name xxx git user name
git config --global user.email xxx git-mail

The project submitted to the main branch (master):

git remote rm origin delete an existing remote connection
git init initialize the local warehouse
touch README.md create README.md file
git add. Add the modified files to the staging
git commit -m "first commit" will be submitted to the temporary files to the local current branch
git remote add origin https: //xxxxxxx.xx/xx/ local warehouse connect to a remote repository
git push -u origin master will push the local repository file to the remote master branch

The main branch code to pull dev branch:

git branch -a view of all remote branch
git checkout -b dev origin / dev create dev branch and remote branch dev update to the local branch local
git pull origin master --allow-unrelated-histories to update the master branch of the current branch
(Execute git pull origin master error is thrown refusing to merge unrelated histories)

Error Resolution:

command: 
git push origin master
        failed to push some refs to 'https://github.com/CrazyDony/text.git'
        hint: Updates were rejected because the tip of your current branch is behind
        hint: its remote counterpart. Integrate the remote changes (e.g.
        hint: 'git pull ...') before pushing again.
        hint: See the 'Note about fast-forwards' in 'git push --help' for details.
The reason: he is older than the main branch version
solve:
git push -u origin master-f
        Counting objects: 35, done.
        Delta compression using up to 4 threads.
        Compressing objects: 100% (29/29), done.
        Writing objects: 100% (35/35), 10.15 KiB | 0 bytes/s, done.
        Total 35 (delta 5), reused 0 (delta 0)
        To https://github.com/CrazyDony/text.git
        + aa70966...f64b22a master -> master (forced update)
        Branch master set up to track remote branch master from origin. 完成

Branches merge:

The dev branches merged into the master branch:

git  checkout master
git go dev

Guess you like

Origin www.cnblogs.com/XYYCKL/p/11800108.html