##Uncommitted changes |
|
The file is not tracked and is not within git version management |
|
Added to the staging area | |
Just joined the staging area |
|
Ignore specific files in Eclipse
Switch the directory to Navigator and you will find that there are some hidden files (Eclipse feature files):
- .classpath file
- .project file
- All files in the .settings directory
These are files maintained by Eclipse to manage the projects we created, and have nothing to do with the developed code. Direct relationship. It's best not to track them in Git, i.e. just ignore them.
Why should Eclipse specific files be ignored?
It is difficult to ensure that everyone in the same team uses the same IDE tool. When the IDE tools are different, the relevant project-specific files may be different. If these files are added to version control, it is likely that conflicts will need to be resolved for these files during development.
Right-click on the project and select Team→Commit to enter the view interface:
Ignore the operation of Eclipse specific files:
Step one: Create a Java.gitignore file in the same directory as .gitconfig
and write the following content.
This directory is usually under the user folder.
# 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.xmlhs_err_pid*.classpath.project.settings
target
Step 2: Modify the .gitconfig
configuration file and add the following code to it
[core]
excludesfile = C:/Users/Hudie/Java.gitignore[这里填的是自己创建的Java.gitignore文件的绝对路径]
Step 3: Restart Eclipse. At this point, Eclipse has completely ignored these feature files.
Basic operations of local libraries in Eclipse
-
Add to staging area: Equivalent to
git add [file name]
Command
(In addition to clicking the Add to Index button below, you can also drag and drop.)
At this time, you can write comments in Commit Message
After that, click the Commit
button to submit to the local library:
##Push the local warehouse to the remote library
Create a remote library:
Return to Eclipse, click Team→Remote→Push
After pasting the Http address of the remote library into the URI, Click next:
After clicking Add All Branches Spec, click next:
You can enter log information in the interface below.
Successful push:
Clone the project of the remote library to the local
Oxygen Eclipse( The cloning project operations of Kepler Eclipse (with a higher version of Eclipse) and Kepler Eclipse (with a lower version of Eclipse) are different. The following demonstrates the operation of Oxygen Eclipse (the Eclipse version is higher) to clone the project from GitHub to the local Eclipse:
Step 1: Right-click on the eclipse project and select import to import the # in Git ##Projects form GitOptions:<p><img src="https://img.php.cn/upload/article/000/000/052/c6a6d7f698878501d7fdc16c9c6aa759-21.png" alt="Take a look at the Git&GitHub graphical interface operation and the use of Git plug-in in Eclipse"><br> 然后选择<code>Clone URI
:
选择Eclipse的工作区目录:
选择作为一个普通的工程导入:
此时已经导入成功,但是并没有识别为Eclipse的项目,这样的目录是无法使用的。
将其转换为Maven工程:
此时,就已经符合Eclipse的开发了。
注意:Kepler Eclipse(Eclipse版本较低)不能保存到当前Eclipse工作区目录。
解决方案是:不要放入工作区。
在Eclipse中解决冲突
演示冲突的产生:
首先将一个项目push到远程库:
此时若push推送
另一个项目,会出现拒绝push
提示:
正确的方式是先pull拉取
下来,再进行操作:
此时可以看到冲突已经产生:
可以使用图形化界面的Merge Tool
接下来就可以commit到本地库,进而push到远程库了。
如果在Eclipse中进行push时出现错误提示:The current branch is not configured for pull No value for key remote.origin,可以通过该项目.git
目录下的config
文件,添加下面两项内容:
[remote "origin"]
url = https://github.com/FanChenALiang/TestGIt.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master