개발 잡부

콘솔에서 깃 초기화부터 깃허브에 업로드까지

금붕어 송인호 2021. 6. 23. 15:29
728x90

맨날 깃허브에서 만든 다음에 clone해서 폴더를 만들어서 썼다.

하지만 역시 정석이라고 한다면 콘솔에서 git init을 하고 깃 허브에 등록하는게 아닌가 싶다.

맨날 몰라서 그냥 깃허브에서 어찌어찌했는데 이번게 공부를 해보기로 했다.


깃 초기화

git init

엥? npx create-react-app으로 했더니 깃이 이미 있었나보다.

아무튼 재초기화 되었다고 하니까 계속 진행을 해보자

git init은 현재 폴더에 깃 레포지토리로 만든다는 것이다. 그래서 .git 폴더가 생성된다.


내 깃허브 계정에 연결하기

평소대로라면 Github Desktop을 통해 그냥 'Publish repository'를 눌러서 해치웠겠지만,

오늘은 콘솔을 통해서 해보기로 했다.

// 브런치 확인
git branch

// 이 깃의 리모트 레포지토리를 연결
git remote add origin 주소

// 등록된 remote 확인
git remote -v

// 푸쉬하기
git push origin 브랜치

// git push만 해도 자동으로 정해진 브랜치로 푸쉬되게 하기
git push --set-upstream origin master


Username, Password등록하기

이렇게 하면 이제 이런 메시지가 pull / push 할 때마다 뜬다

자, Username과 password를 등록해서 귀찮음을 줄여보자

// 단일 레포지토리
git config credential.helper store

// 전체 레포지토리
git config --global credential.helper store

다음의 커맨드를 입력하고, git pull을 해서 Username과 password를 입력하면 다음부터는 안 쳐도 된다.


출처

https://docs.github.com/en/github/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line

 

Adding an existing project to GitHub using the command line - GitHub Docs

If you are migrating your project from CodePlex, read the migration guide for more information. Warning: Never git add, commit, or push sensitive information to a remote repository. Sensitive information can include, but is not limited to: Passwords SSH ke

docs.github.com

https://subji.github.io/posts/2020/01/17/git-hotwtosaveusernameandpassword-solve

 

Git username, password 저장 방법 (how to save username and password in git)

| 문제git pull, git push 하는데 있어서 계속 비밀번호를 입력해야되서 번거로웠다. 그래서 비밀번호를 입력하지 않고 저장해서 사용하는 방법을 찾아보았다.| 과정 git config credential.password={password} =

subji.github.io