In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
1. Create a project repository on GitHub
1) first, sign up for a GitHub account and log in, and then start creating a warehouse
2) enter project information:
3) complete the creation:
So far, the address of the warehouse on GitHub is: https://github.com/dengshuangfu/github-demo.git
2. Create a local warehouse
1) create a project using Maven
Mvn archetype:generate-DgroupId=com.dsf.demo-DartifactId=github-demo-DarchetypeArtifactId=maven-archetype-quickstart-Dversion=1.0-DinteractiveMode=false
2) initialize the git repository
Switch to the root path (the path where pmo.xml is located) and execute the following command to initialize the git repository
Git init
3) use warehouse to manage files
Git status
When prompted that there are untracked files, we add the files to the temporary storage area with the following instructions
Git add.
Then submit the file to the warehouse with the following instructions
Git commit-m 'initial commit'
Check the branch status of git warehouse
Gitk-all
A visual window will pop up
It can be seen that there is only one submission currently.
Then we create the application.yml file under resources, then submit it to the warehouse, and then execute the gitk command
3. Push the local warehouse to GitHub
1) add remote warehouse address
Git remote add origin https://github.com/dengshuangfu/github-demo.git
2) locally associate with the remote master and push it to the master of the remote warehouse
Git push-u origin master
The error message is as follows
To https://github.com/dengshuangfu/github-demo.git! [rejected] master-> master (fetch first) error: failed to push some refs to 'https://github.com/dengshuangfu/github-demo.git'hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g.,' git pull...') Before pushing again.hint: See the 'Note about fast-forwards' in' git push-- help' for details.
The reason for this error is that there are commits on the remote branch that do not exist in the local branch, because ".gitignore" and "README.md" files currently exist in the remote repository, so we need to grab and merge all the contents of the remote warehouse (git pull origin master-- allow-unrelated-histories) before pushing the local warehouse data (git push origin master).
Push
At this point, GitHub already has the warehouse content we pushed.
Let's use the gitk command to check the branches as follows
Note: differences in push when setting the following configuration
Git config-- global push.default matchingorgit config-- global push.default simple [default]
Matching:git will push the local branch to a remote branch that already has the same name.
Simple: only the current branch is pushed to the corresponding remote branch.
4, with Git push instruction parsing
The general form of git push is git push.
For example, git push origin master:refs/for/master is to push the local master branch to the corresponding master branch on the remote host origin. Origin is the remote host name, the first master is the local branch name, and the second master is the remote branch name.
1) git push origin master
If the remote branch is omitted, as above means that the local branch is pushed to the remote branch with which the tracking relationship exists (usually with the same name), and if the remote branch does not exist, it will be created
2) git push origin: refs/for/master
If the local branch name is omitted, the specified remote branch is deleted because this is equivalent to pushing an empty local branch to the remote branch, equivalent to git push origin-- delete master
3) git push origin
If the current branch has a tracking relationship with the remote branch, both the local branch and the remote branch can be omitted and the current branch can be pushed to the corresponding branch of the origin host
4) git push
If the current branch has only one remote branch, then the hostname can be omitted, such as git push, and you can use git branch-r to view the remote branch name
5) other commands of git push
Git push-u origin master if the current branch has a tracking relationship with multiple hosts, you can use the-u parameter to specify a default host, so that you can use git push without any parameters, git push without any parameters, and only the current branch is pushed by default. This is called simple mode, and there is also a matching method that pushes all local branches with corresponding remote branches. Before Git 2.0, matching is used by default. Now change to simple mode. If you want to change the settings, use the git config command. Git config-global push.default matching OR git config-global push.default simple You can use git config-l to view the configuration git push-- all origin when you encounter this situation, that is, all local branches are pushed to the remote host regardless of whether there is a corresponding remote branch or not. When you need the-all option git push-- force origin git push, you need to update the local git pull first to be consistent with the server version. If the local version library is lower than the one on the remote server, you will generally be prompted to update git pull. If you must submit, you can use this command. Git push origin-- tags / / git push will not push branches. If you must push tags, you can use this command.
6) about refs/for
/ / the significance of refs/for is that after we submit the code to the server, we need to go through code review before merge, while refs/heads does not need it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.