当前位置:   article > 正文

java工具:git得使用及maven私服搭建_git直接配置到私有化maven搭建

git直接配置到私有化maven搭建

本文详细介绍git在项目开发过程中得使用,及maven github私服得搭建

Git:分布式版本控制系统(SVN集中式版本控制系统)
svn:只有一台中央服务器,一起下载代码,一起提交代码
git:每个人都有自己的本地版本库,将自己的代码推送给别人
下载地址:https://git-scm.com/download/win

安装完成:右键选择Git Bash Here 进入命令行
配置:$ git config --global user.name “Your Name”
$ git config --global user.email "email@example.com"
安装配置完毕====
基本命令:
1.创建本地版本库,进入文件夹右键选择Git Bash Here 执行git init
2.新建文件:(touch/vi a.txt)
3.git status(查看文件是否纳入版本库)
4.git add a.txt (纳入git暂存区)
5.git commit -m “提交注释”(纳入到版本库)
6.git log a.txt (查看操作日志/git log --pretty=oneline a.txt 一行显示日志)
7.git diff a.txt (查看工作空间和本地库的差异)
8.git reset --hard HEAD(回退到上一版本) 9.git reflog a.txt(查看所有的操作记录并带有版本号) 10.git reset --hard HEAD 9中的版本号(回到某个版本) 11.git reset --hard HEAD3(回到第3版本)
12.git checkout --a.txt回撤版本(回撤的是自己的本地空间)
三区:
工作区:自己的电脑
暂存区:工作去add到暂存区
版本区:暂存区commit到版本区
push到git服务器

创建分支:
1.git branch 查看分支
2.git branch name 分支创建(会把master主分支东西带过来)
3.git checkout dev 切换分支dev
4.git branch master/切换到主分支 git merge dev/将dev分支合并到master
5.解决合并冲突:
cat 冲突文件===>删除掉<<<<>>>>====符号
在进行提交
6.git branch -d dev 删除分支
7.git branch -b test新建切换到分支

github:托管git项目
一:本地上传远程库
1.在git上新建项目
2.在本地git命令行执行:git remote add origin https://github.com/SongFuShuang/ao-test.git连接到github服务器
3.git push -u origin master 将本地项目推送到github服务器
4.编辑本地文件–>add—>commit—>git push origin master 推送到远程库
5.远程库更改:git pull origin master—>下载到本地
二:从github服务器下载代码
1.git clone https://github.com/SongFuShuang/ao2.git

三:fork:使用fork相当于你在原项目的主分支上又建立了一个分支,你可以在该分支上任意修改。如果想将你的修改合并到原项目中时,可以pull requests
(接收到其他用户得fork后同意后合并)
四:图形化工具TortoiseGit:地址https://download.tortoisegit.org
1.创建仓库:新建文件—>先add("+")—>commit(“√”) 回退:reset master to this commit是重置master中选择Hard其余得都被干掉不会保留
回撤/还原:revert change by this commit 把提交得版本还原到上一个版本(双重revert能找回之前得还原)
2.创建分支:
先create branch 在switch/checkout切换分支 修改分支内容commit 在switch/checkout切换到主分支,在merge
冲突解决:edit conflicts冲突解决
3.远程库操作连接:push pull
4.Egit:eclipse得插件(有的eclipse整合好了有的没有)
配置:Git–>Configuration—>配置用户名密码(也可能会有的整合SSH私钥)
eclipse项目上传git时:
项目share后会出现?在各个文件上,之后在右键add index加入到本地库出现+号 commit后变为黄色药瓶
推送到远程:Remote–>push
更新代码:Pull
可能会报错:The current branch is not configured for pull
No value for key remote.origin.url found in configuration
解决:Git–>Configuration–>Repository Setting 如图1:
图1
添加如下:
[branch “master”]
remote = origin
merge = refs/heads/master
[remote “origin”]
url = https://github.com/androidzhaoxiaogang/rocket.git(修改为自己的url)
fetch = +refs/heads/:refs/remotes/origin/
push = refs/heads/master:refs/heads/master
小操作:
当服务器比自己得代码新:可以使用synchronized Workspace同步代码 会切换到视图:共四个图标 分别代表:服务器最新 本地最新 服务器本地最新 冲突
eclipse解决冲突:先pull整理完在add index 在push

maven私服搭建:
maven私服好处:1.节约外网带宽2.加速maven的构建3.部署自己的基础类库

jdk1.8 maven Nexus-2.x
下载地址:https://help.sonatype.com/repomanager2/download
步骤:
cd /usr/local
mkdir nexus
tar -zxvf nexus-2.14.11-01-bundle.tar.gz -C /usr/local/nexus
检查nexus的端口号和配置
1.nexus-2.14.11-01操作页面 sonatype-work类似maven仓库
2.端口号:nexus-2.14.11-01/conf下:nexus.properties application-port=1314
3.修改系统用户为linux用户:nexus-2.14.11-01/bin/nexus脚本:RUN_AS_USER=root
4.修改防火墙暴露1314端口号
5.启动访问:bin:./nexus start
6.http://129.28.129.120:1314/nexus/#welcome
7.默认用户 admin admin123
8.仓库介绍:
group:Nexus通过管理仓库组来管理多个仓库
hostd:发布内部jar包或第三方项目架构及无法从公共仓库下载的jar包(oracle的驱动)
releases:所有非快照工程发布到这里
snapshots:存放快照模块及以SNAPSHOT结尾的工程
3rd-party:第三方依赖库,内部人员自行下载发布到此
proxy:代理仓库存储远程中央仓库的索引和构建信息
设置代理仓库:
在这里插入图片描述

1.修改maven配置文件
在这里插入图片描述
2.注释掉mirror
3.修改
在这里插入图片描述
4.在项目中的pom配置
在这里插入图片描述
5.发布快照:run build deploy

6.附件:maven的setting配置:

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository  -->
  <localRepository>E:/javatool/rep/inst</localRepository>


  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
	-->
	<server>
      <id>nexus-releases</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
	<server>
      <id>nexus-snapshots</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
    
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     
 
	 <mirror>  
		<id>nexus-aliyun</id>  
		<mirrorOf>central</mirrorOf>    
		<name>Nexus aliyun</name>  
		<url>http://maven.aliyun.com/nexus/content/groups/public</url>  
	 </mirror> 
	 -->
  </mirrors>
  <profiles>
  		  <profile>    
			<id>jdk-1.8</id>    
			 <activation>    
				  <activeByDefault>true</activeByDefault>    
				  <jdk>1.8</jdk>    
			  </activation>    
		<properties>    
		<maven.compiler.source>1.8</maven.compiler.source>    
		<maven.compiler.target>1.8</maven.compiler.target>    
		<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>    
		</properties>    
       </profile>
	   <profile>  
        <id>nexusId</id> 
        <activation>    
		    <activeByDefault>false</activeByDefault>    
		    <jdk>1.8</jdk>    
	    </activation>  		
        <repositories>  
          <repository>  
            <id>local-nexus</id>  
            <url>http://129.28.129.120:1314/nexus/content/groups/public/</url>  
            <releases>  
              <enabled>true</enabled>  
            </releases>  
            <snapshots>  
              <enabled>true</enabled>  
            </snapshots>  
          </repository>  
        </repositories>  
		 <pluginRepositories>
          <pluginRepository>
          <id>nexus</id>
          <url>http://129.28.129.120:1314/nexus/content/groups/public/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
             <enabled>true</enabled>
         </snapshots>
      </pluginRepository>
   </pluginRepositories>
      </profile>  
  </profiles>
  <activeProfiles>
    <activeProfile>nexusId</activeProfile>
  </activeProfiles>
</settings>

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/130625
推荐阅读
相关标签
  

闽ICP备14008679号