LoginSignup
0
0

Github Commit and Push command (Memorandum)

Last updated at Posted at 2024-04-06

How to Github

For busy people

I got you. All you need is these.

For new projects

Terminal
cd .../.../.../project_name
git config --global user.email your-mail-address@mail.com
git config --global user.name username
git init
git add .
git commit -m "comments"
git remote add origin your-repository-url.com
git push origin master

For registered projects

Terminal
cd .../.../.../project_name
git add .
git commit -m "comments"
git push origin master

Prerequisite

If you are totally new to programming and 'githubbing', you might not have an account for Github.

1. Get an account

Please get an account at Github.

2. Create a sample project

I suppose you've got something. You surely do not need any large projects to show.

If you don't got any, just copy the code below and paste it to memo. Then save it as sample.py.

sample.py
print('Hello, noobs!')

How to commit and push a project to Github

It's not hard. only takes about 5 minutes as whole process.

1. Register a project to Github

First, login to Github and create a new repository. You can also do that by accessing this link.
https://github.com/new

Create_a_new_repo

2. Go to the Terminal you were working on

Just got to the terminal.

Terminal
cd /Users/Username/Desktop/project

3. Setting up your user info

Setting up your user info. Write your username and mail address that you've used to setup a Github account.

Terminal
git config --global user.email "your-mail-address@mail.com"
git config --global user.name "your-user-name"

You might get the following error unless you do the setups above.

Error
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

4. Initializing Git

Initialize Git. Yeah, initialize it, ... initialize.

Terminal
git init

5. Add files that you've changed

The dot means adding all the files you've changed. It might take a while.

Terminal
git add .

6. Commit the files

Commit it.

Terminal
git commit -m "any comments"

7. Register repository

Go to your github account and access the repository. Then copy the HTTPS link.

https_link

Just paste it off. You don't need the parenthesis.

Terminal
git remote add origin (your-url-link)

8. Push the files

Finally, push the files to remote repository!

Terminal
git push origin master

There you have it.

Errors I got while pushing

I got this following error while pushing.

Error
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400

Solved it by running the code below.

Terminal
git config --global http.postBuffer 524288000

I also got this error. Too large.

Error
remote: error: GH001: Large files detected. You may want to try Git Large File Storage

Nothing you can do about it. Maybe trying Github Pro would help? but who knows.
Github-pro

when asked for merge

Terminal
git merge --allow-unrelated-histories origin/main
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0