Java 기초 - GitHub에 코드 업로드

김성태·2023년 2월 23일
0

내 GitHub에 IntelliJ에서 작성한 코드를 업로드할 수 있다.

  1. Git 설치

https://git-scm.com/download

  1. Intelli J 에서 Terminal에 Git Bash 실행

  2. 아래 순서로 실행

    #GIT 세팅(최초 한번만)
    git config --global init.defaultBranch main
    git config --global user.name "본인 깃허브 ID" (SungT318)
    git config --global user.email "깃허브 가입시 사용한 이메일" (###@naver.com)
    #원격 리포지터리 생성
    https://github.com/new
    https://github.com/SungT318/test
    #로컬 리포지터리 생성
    git init
    #.gitignore 파일 생성 (아래내용 참고)
    #장바구니에 담기

    git status # 확인
    git add .
    git status # 확인
    #커밋
    git commit -m "프로젝트 세팅"
    git status # 확인
    git log
    #파일 수정
    git status # 확인
    #장바구니에 담기
    git add .
    git status # 확인
    #커밋
    git commit -m "Hello There 로 변경"
    git status
    git log
    #로컬 리포지터리에 원격 리포지터리를 연결
    git remote -v # 확인
    git remote add origin https://github.com/SungT318/test
    git remote remove origin -> 이걸 통해서 origin 을 삭제할 수 있다.
    git remote -v # 확인
    #푸시
    git push origin main

아래와 같이 GitHub에 Repository를 만든 뒤 위 작업을 거치면

아래와 같이 Intell J에서 작성한 내용이 들어간다.

#.gitignore(New-file)

#.gitignore 소스코드

# Created by https://www.toptal.com/developers/gitignore/api/intellij,java
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,java

### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn.  Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/

# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml

# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/

# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$

# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml

# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml

### Java ###
# 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*
replay_pid*

# End of https://www.toptal.com/developers/gitignore/api/intellij,java
profile
오늘도 화이팅!

0개의 댓글

관련 채용 정보