<--! Git(깃) : 명령어 정리 - 처음 그리고 추가 프로젝트 올리기 -->

Git(깃) : 명령어 정리 - 처음 그리고 추가 프로젝트 올리기

필그램

·

2017. 11. 14. 00:37

아래 내용은 전체 디렉토리를 올리는 것입니다.


이전에 초보 따라해보기 : https://nolboo.kim/blog/2013/10/06/github-for-beginner/  로 해보니 잘되더군요.


이후 버전이라고 보시면 됩니다.


Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.


git init



git add .
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.


git commit -m "First commit"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.



https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/





[디렉토리 올릴때]


You can add files using git add, example git add READMEgit add <folder>/*, or even git add *

Then use git commit -m "<Message-버전설명이죠>" to commit files

Finally, git push -u origin master to push files.

When you make modifications run git status which gives you the list of files modified, add them using git add * for everything or you can specify each file individually, then git commit -m <message> and finally, git push -u origin master


왠지 깃을 시작해 보는게 참  어려웠습니다.

다른 프로그램 처럼 그냥 따라서 해보고, 지우고 하는 것이 활용법을 늘리는 것입니다.


[깃(GIt)의 user.name 확인하기]


두번째 깃을 올리면서 user.name 확인 해봤습니다.

초보용과 달리, 두번째는  user.name 을 설정할 필요없이, 사용하면 됩니다.

터미널 에서 아래를 치면

git config user.name

본인의 이름이 나옵니다.


Jake Lee

*  두번째 방법은


git config --list

user.name=Jake Lee

user.email=jake@gmail.com

filter.lfs.clean=git-lfs clean -- %f

filter.lfs.smudge=git-lfs smudge -- %f

filter.lfs.process=git-lfs filter-process

filter.lfs.required=true

네, 메일까지 확인되는데.. 아래는 잘 모르겠네요.


[두번째 프로젝트 만들기]


깃의 이름을 확인했으면, 


1. 먼저 깃 온라인에서 프로젝트를 만듭니다.

https://github.com/jake/Ssppss.git  이라는 것을 복사하고


2. 먼저 터미널에서 해당 디렉토리로 갑니다.

>pwd 해보면(맥, 리눅스),

/Users/jake/dev/Project/Ssppss  라고 나옵니다. (온라인 저장소와 이름이 같아야 한답니다)


3. git init 을 칩니다

 > Initialized empty Git repository in /Users/jake/dev/Project/Ssppss  라고 나옵니다. 


4. 디렉토리에 코드를 작성하고


5.  git add  를 사용해 파일을 올립니다. (예: test.txt)

  git add test.txt


5-2. 기존의 디렉토리라면,

  위에 처럼 git add .

  해야겠죠. 


6.  git commit  을 칩니다.


[깃에 연결하기]

이게 커밋한것을 깃에 연결할 차례입니다.


7. git remote add origin https://github.com/jake/Ssppss.git  라고 칩니다.

미리 만들어둔 깃의 온라인 저장소와 로컬 디렉토리를 연결한 것입니다.


잘 연결 됬는지 확인을 위해 다음을 칩니다.

8. git remote -v


그러면,

origin https://github.com/jake/Ssppss.git (fetch)

origin https://github.com/jake/Ssppss.git (push)

라고 연결된 것을 확인할 수 있습니다.


9. git push -u origin master

push하여 올립니다.


결과로 아래와 같이 보여 줍니다.

Counting objects: 75, done.

Delta compression using up to 4 threads.

Compressing objects: 100% (55/55), done.

Writing objects: 100% (75/75), 126.10 KiB | 9.01 MiB/s, done.

Total 75 (delta 1), reused 0 (delta 0)

remote: Resolving deltas: 100% (1/1), done.

To https://github.com/jake/Ssppss.git

 * [new branch]      master -> master

Branch master set up to track remote branch master from origin.


이상 입니다. 




[참고 블로그]


초보 따라해보기 : https://nolboo.kim/blog/2013/10/06/github-for-beginner/

이해 증진 : http://rogerdudler.github.io/git-guide/index.ko.html


반응형