🗄️git

git에 파일 올리기/ git 수정코드 올리기

하얀성 2023. 5. 25. 17:19

마우스 부분만 git add . 으로 치고

주소도 개인 깃주소로 바꿔서 순서대로 한문장씩 치면 된다.

윗쪽은 저장공간을 처음만들 때 코드, 아래는 이미 만들어져있는 공간에 push하는 코드이다.


…or create a new repository on the command line

 
echo "# git-practice" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/elecch/git-practice.git
git push -u origin main

…or push an existing repository from the command line

 
git remote add origin https://github.com/elecch/git-practice.git
git branch -M main
git push -u origin main

 

main -> main forward! 이런 에러가 뜨면 이미 깃과 연결이 되어있으니.. 조치를 취해달라는 의미임.

깃 통로를 바꿔주던가.

아니면 깃 통로를 삭제하고 새롭게 설치해주던가. 나는 깃 통로를 바꾸는 건 아직 잘 몰라서

깃 통로를 삭제하고 재설치하는 편이다.


<git 수정코드 올리기>

git add .

git commit -m "메세지 내용"

git push origin main


 

npm run build로 React 앱을 가동시킨 뒤,

npm run deploy를 통해 git의 main이 아닌 다른 공간인 gh-pages에 저장가능

물론 아래 코드처럼 연결할 주소와 deploy: 명령어를 json에 입혀줘야한다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
  "homepage": "https://elecch.github.io/real_cat_Project",
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "gh-pages": "^5.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}
 
cs

 

이걸 굳이하는 이유는 React App인 상태로 올리기 위함이다.