更新時間:2023-02-15 16:31:58 來源:動力節點 瀏覽1758次
idea中如何配置git以及在idea中初始化git呢:
問題說明:
解決方法一:
◆打開IDEA,按照路徑 Fie--》Settings --》 Tools --》Terminal 找到后設置右邊的Shell path(自己安裝的Git路徑下相對位置),如下圖所示
不完美之處:當我們點擊idea中的Terminal終端時,會自動彈出Windows安裝的bash窗口,如下圖所示:
解決方法二:
◆更改路徑即可 git\bin\bash.exe 或 Git\bin\sh.exe 然后重新啟動idea即可
********************88注意:每次更改完成后需要重新啟動IDEA******************
=============================記錄End=============================
git在idea中使用:
(1)創建README.md文件
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ touch README.md
(2)創建.gitignore文件(用于忽略上傳的文件)
#提交到碼云上面忽略的東西配置
*.class
#package file
*.war
*.ear
*.orig
target/
.settings/
.project
.classpath
.idea/
/idea/
*.ipr
*.iml
*.iws
*.log
*.cache
*.diff
*.patch
*.tmp
.DS_Store
Thumbs.db
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ touch .gitignore
(3)初始化git
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git init
Initialized empty Git repository in F:/workspace/imallproject/.git/
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
查看git狀態:現在是在master上(一般分支開發主干合并)
$ git status
On branch master
(4)commit提示錯誤,先git add一下
Initial commit
Untracked files:
(use "git add ..." to include in what will be committed)
.gitignore
README.md
pom.xml
src/
nothing added to commit but untracked files present (use "git add" to track)
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git add .
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached ..." to unstage)
new file: .gitignore
new file: README.md
new file: pom.xml
new file: src/main/webapp/WEB-INF/web.xml
new file: src/main/webapp/index.jsp
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git commit -am 'first commit '
[master (root-commit) 5ef0663] first commit
5 files changed, 65 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md
create mode 100644 pom.xml
create mode 100644 src/main/webapp/WEB-INF/web.xml
create mode 100644 src/main/webapp/index.jsp
git連接到碼云倉庫:
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git remote add origin [email protected]:marrymayun/imalllearning.git
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git branch
* master
(5)推送
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git push -u origin master
The authenticity of host 'git.oschina.net (120.55.226.24)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git pull
The authenticity of host 'git.oschina.net (120.55.226.24)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,120.55.226.24' (ECDSA) to the list of known hosts.
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From git.oschina.net:marrymayun/imalllearning
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/ master
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git push -u -f origin master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (11/11), 1.29 KiB | 0 bytes/s, done.
Total 11 (delta 0), reused 0 (delta 0)
To [email protected]:marrymayun/imalllearning.git
+ a5a27d2...5ef0663 master -> master (forced update)
Branch master set up to track remote branch master from origin.
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git branch
* master
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git branch -r
origin/master
在master下創建分支v1.0
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (master)
$ git checkout -b v1.0 origin/master
Branch v1.0 set up to track remote branch master from origin.
Switched to a new branch 'v1.0'
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (v1.0)
$ git branch
master
* v1.0
推送到分支,我們在分支開發,主干合并
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (v1.0)
$ git push origin HEAD -u
Total 0 (delta 0), reused 0 (delta 0)
To [email protected]:marrymayun/imalllearning.git
* [new branch] HEAD -> v1.0
Branch v1.0 set up to track remote branch v1.0 from origin.
fengli@DESKTOP-FEQ1N4I MINGW32 /f/workspace/imallproject (v1.0)
$
完成:
至此在idea中初始化git完成。
以上就是動力節點小編介紹的"idea配置git插件以及初始化的使用",希望對大家有幫助,如有疑問,請在線咨詢,有專業老師隨時為您務。
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習