0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

git pushまでの手順(コンフリクトなし版)

Last updated at Posted at 2024-07-06

目的

業務効率化資料

背景

今回は、昔プッシュしていたJavaコードに対して、Java17機能でsealedの対応が
新たに加わったため、コードの修正対応をしてみました。

コマンドで覚えるGit編

(★印はポイントになります)

PS C:\work\javaProgramSample\src\demo> git status    (★)                                                                      
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   sample1/Rectangle.java
        modified:   sample1/Shape.java
        modified:   sample1/Triangle.java
        (*ステージングされていないファイルは赤くなります)

no changes added to commit (use "git add" and/or "git commit -a")
PS C:\work\javaProgramSample\src\demo> git add sample1/Rectangle.java  (★)
PS C:\work\javaProgramSample\src\demo> git add sample1/Shape.java  (★)
PS C:\work\javaProgramSample\src\demo> git add sample1/Triangle.java  (★)
PS C:\work\javaProgramSample\src\demo> git status (★git add できていると緑色になる)
On branch main
Your branch is up to date with 'origin/main'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   sample1/Rectangle.java
        modified:   sample1/Shape.java
        modified:   sample1/Triangle.java

PS C:\work\javaProgramSample\src\demo> git commit -m "Java17対応  sealed付与" (★)
[main 6310f1b] Java17蟇セ蠢・ sealed莉倅ク
 3 files changed, 3 insertions(+), 3 deletions(-)
PS C:\work\javaProgramSample\src\demo> git push (★)
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 601 bytes | 601.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
To https://github.com/xxxxxx/xxxx.git
   d8e4da7..6310f1b  main -> main
PS C:\work\javaProgramSample\src\demo> 

おまけ

tig コマンドを使うと以下のように、一覧で視覚化してくれるのでおすすめです。

image.png

image.png

image.png

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?