Git:与eclipse搭配使用

Git:与eclipse搭配使用

1)工程初始化为本地库

工程 ——》右键 ——》Team ——Share Project

在该目录下创建了本地库

这里可以设置用户签名

2)Eclipse中忽略文件

Navigator可以很清楚的看清文件目录层次

1)概念:Eclipse中特定文件

这些都是Eclipse为了管理我们创建的工程而维护的文件,和我们开发的代码没有直接关系,最好不要在git中进行追踪,也就是把他们忽略

.classpath文件

.project文件

扫描二维码关注公众号,回复: 4210201 查看本文章

.settings目录下所有文件

2)为什么要忽略Eclipse特定文件呢

因为在同一个团队中,大家用的Eclipse版本可能不一样

3)配置忽略文件

GitHub官网样例文件

https://github.com/github/gitignore

https://github.com/github/gitignore/blob/master/java.gitignore

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
官方推荐

在用户~目录下  .gitconfig为全局配置文件

我们自己定义一个文件来存放忽略配置

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.classpath
.project
.settings
target

在 .gitconfig 目录下配置

[user]
    name = 用户名
    email = 邮箱
[core]
    excludesfile = 绝对正确的路径,用/斜线

重启eclipse生效  restart

3)推送到远程库

Add all Branches Spec

4)克隆工程到eclipse

如果是maven工程目录需要转化一下,右键工程

 5)冲突时的比较

猜你喜欢

转载自www.cnblogs.com/it-taosir/p/10012993.html
今日推荐