DEV Community

Mayu Hayakawa
Mayu Hayakawa

Posted on • Edited on

How to push your file to git hub?

The first way
Commit Local repository to Remote repository

1) Create directory and some files on your computer
Image description

1) Create Remote repository on git hub
Push "new button"
Image description
set about repository name, Public or Private, if you need add a README file.
Then push Create repository.
Image description
Did it!
Image description

2) Create Local repository on directory you just made
Command: git init
Image description
-git folder(hidden) appear
Image description

3) Add file to index
?What is Index?
-Index is an area where changes are temporarily stored before commit, and only files added to the index are subject to commit.
command: git add bun.index(👈file's name)
;If you want to commit all files, command: git add .
Image description

4) Commit file to local repository
?What is Commit?
-Commit means the operation of reflecting file additions and changes in the local repository.
Command: git commit -m "some comment"(👈kind of memo)
Image description
You can check the change history including commit messages by entering git log command.
Command: git log
Image description
When you want quit checking log, please enter "q".

5) Linking local and remote repositories
Command: git remote add origin repository's URL(👈You can copy this from your git hub)
Image description
Image description

6) Push file to remote repository
?What is Push?
-Push is to reflect changes in a local repository to a remote repository on GitHub.
Command: git push origin branch's name(👈You can check with command: git branch)
Image description
Image description

Ta-da!
Image description

The second way
Clone source codes from Remote repository on your Local

1) Clone source codes from Remote repository

2) Make your branch
?What is branch?

3) Commit files to branch you made

4) Push file to remote repository

reference(Japanese)
https://tech-blog.rakus.co.jp/entry/20200529/git

Top comments (0)