Git push local project to remote branch (GIT command version)


1. Create a project locally. You can use eclipse, idea and other development tools to create a project. Open the root directory to the next level of the project name

2. Use git client to enter the folder of helloword in the directory above

3. Initialize project git init

4. Add command git add – a of helloword engineering structure

5. Submit git to version – M is the submitted comment

Git commit – M “this is the comment: initialize project”

6. Build the project with remote GIT

7. Configure the remote warehouse. Source is the alias of the remote warehouse xxx.git Your address

git remote add origin

7. Start pushing

Git push < remote host name > < local branch name >: < remote branch name >
git push origin master:master

===If you don’t let the push pull down and then push

Git pull — rebase origin master, which merges the files on gitee with the local library

8. Use git command to push project completion


==The difference between git push origin and git push - U origin master
$ git push origin
The above command indicates that the current branch is pushed to the corresponding branch of the origin host. 
If the current branch has only one trace branch, the host name can be omitted. 
If the current branch has a tracking relationship with multiple hosts, the - U option will specify a default host,
In this way, GIT push can be used without any parameters.
The $git push - U origin master command pushes the local master branch to the origin host, and specifies origin as the default host,
Later, you can use git push without any parameters. Git push without any parameters only pushes the current branch by default, which is called simple mode.
In addition, there is a matching method, which will push all local branches with corresponding remote branches.
Before git 2.0, matching method was adopted by default, but now simple method is adopted by default.


This article about git push local project push to remote branch method (GIT command version) is introduced here. For more related git push local project push to remote branch content, please search previous articles of developer or continue to browse the following related articles. I hope you can support developer more in the future!