파이썬 & 장고/장고(Django)

git hub (깃허브) push , pull, ssh

두뚜 2021. 6. 7. 15:11

$ cd ldh
:~/ldh$ git init local-repo
:~/ldh$ cd local-repo
:~/ldh/local-repo$ echo "version1" >> file1
:~/ldh/local-repo$ touch file2
:~/ldh/local-repo$ git add .

:~/ldh/local-repo$ git commit -m "add file1 file2"

:~/ldh/local-repo$ git remote add origin https://github.com/Do-du/git_test.git
:~/ldh/local-repo$ git remote -v

:~/ldh/local-repo$ git pull origin master --allow-unrelated-histories
:~/ldh/local-repo$ git push -u origin master






:~/ldh/local-repo$ touch file3
:~/ldh/local-repo$ echo "version2" >> file3
:~/ldh/local-repo$ git commit -am "version2"

:~/ldh/local-repo$ git add file3
:~/ldh/local-repo$ git commit -am "version2"

:~/ldh/local-repo$ git push origin master

 



:~/ldh/local-repo$ ls
file1 file2 file3

:~/ldh/local-repo$ git pull origin master

:~/ldh/local-repo$ ls
file1 file2 file3 remote_file_test



ssh를 이용해 로그인

:~/ldh/local-repo$ ssh-keygen

:~/ldh$ cat /home/student/.ssh/id_rsa.pub


setting -> SSH and GPG keys




:~/ldh$ cd local-repo/
:~/ldh/local-repo$ git remote set-url origin git@github.com:DO-du/git_test.git

:~/ldh/local-repo$ git remote update origin



:~/ldh/local-repo$ echo "version5" >> file5
:~/ldh/local-repo$ git add file5
:~/ldh/local-repo$ git commit -m "create file5"

:~/ldh/local-repo$ git log --branches

:~/ldh/local-repo$ git push

 





master -> main

:~/ldh/local-repo$ git checkout main
:~/ldh/local-repo$ git log

:~/ldh/local-repo$ ls
file1 file2 file3 file5 main remote_file_test
:~/ldh/local-repo$ git merge master (안됨)
:~/ldh/local-repo$ git pull origin master --allow-unrelated-histories

:~/ldh/local-repo$ git push