How to push your local Repository to github

How to push your local Repository to github?
As usual I was too lazy to check it out. At last I decided to check it out in https://github.com/and a git-friend Stacey Burns sent me a step-by-step link. It finally worked.

Actually I plan to write a book on Python programming language. A beginner’s like me would get help from that.
I want to keep all codes in a git repository so that everybody can download them.
I just want to share my experience.
First Step: create a repository in github. I created a repository ‘PlayWithPython’
Second Step: open your terminal and ‘cd’ to your ‘Project Folder’ that you have planned to push to your git repository. I have a folder called ‘PlayWithpython’ and write a sample python code called ‘first.py’ (this is for testing purpose)
Third Step: type – ‘git init’
// it will initialize your local repository
Fourth Step: type – ‘add .’
Fifth Step: type – ‘git commit -m “First Cmmit”‘
Sixth Step: type – ‘git remote add origin https://github.com/12reach/PlayWithPython.git’
Seventh Step: type – ‘git push -u origin master’
It is done. Now you can check your git repository.
I give the steps below.
I hope it helps.

root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# ls
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# nano first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# ls
first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git init
Initialized empty Git repository in /home/ss/GIT/MyGitFirst/newrepo/PlayWithPython/.git/
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git add .
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git commit -m "First Cmmit"
[master (root-commit) 6022f14] First Cmmit
Committer: root
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

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

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

1 file changed, 4 insertions(+)
create mode 100644 first.py
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git remote add origin https://github.com/12reach/PlayWithPython.git
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython# git push -u origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
Counting objects: 3, done.
Writing objects: 100% (3/3), 254 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/12reach/PlayWithPython.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
root@kali:/home/ss/GIT/MyGitFirst/newrepo/PlayWithPython#

Another More complete pull and push took place here:

hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git init
Initialized empty Git repository in /home/hagudu/PlayWithPython/.git/
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git add .
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git commit -m 'initial commit'
[master (root-commit) aee9b1c] initial commit
91 files changed, 3589 insertions(+)
create mode 100644 Databases/MyFirstSQLiteDB.db
create mode 100644 Databases/MySQLite1.py
create mode 100644 Databases/__pycache__/MySQLite1.cpython-34.pyc
create mode 100644 Databases/__pycache__/python_mysql_dbconfig.cpython-34.pyc
create mode 100644 Databases/config.ini
create mode 100644 Databases/database-test1.py
create mode 100644 Databases/mysqldb-test1.py
create mode 100644 Databases/mysqldb_test2.py
create mode 100644 Databases/python_mysql_dbconfig.py
create mode 100644 Databases/query_with_fetchall.py
create mode 100644 Databases/query_with_fetchmany.py
create mode 100644 Databases/retrieve_mysql_data.py
create mode 100644 Databases/test.db
create mode 100644 Databases/test1.db
create mode 100644 Debugging/MyFirstSQLiteDB.db
create mode 100644 Debugging/unittests.py
create mode 100644 FileIO/files.py
create mode 100644 FileIO/files.txt
create mode 100644 FileIO/new.txt
create mode 100644 General Syntax/assigining_values.py
create mode 100644 General Syntax/conditionals
create mode 100644 General Syntax/conditionals.py
create mode 100644 General Syntax/functions
create mode 100644 General Syntax/functions.py
create mode 100644 General Syntax/objects.py
create mode 100644 General Syntax/standard.py
create mode 100644 Loops/file.txt
create mode 100644 Loops/forloops.py
create mode 100644 Loops/while_loops.py
create mode 100644 MySQL_Connector/__pycache__/mysql_config.cpython-34.pyc
create mode 100644 MySQL_Connector/connection-test.py
create mode 100644 MySQL_Connector/deletes.py
create mode 100644 MySQL_Connector/inserts.py
create mode 100644 MySQL_Connector/mysql_config.ini
create mode 100644 MySQL_Connector/mysql_config.py
create mode 100644 MySQL_Connector/retrieve-blob.py
create mode 100644 MySQL_Connector/retrieve.py
create mode 100644 MySQL_Connector/retrieve_by_dbconfig.py
create mode 100644 MySQL_Connector/update-blob.py
create mode 100644 MySQL_Connector/updates.py
create mode 100644 README.md
create mode 100644 Variables, Objects and Values/ListsTuples.py
create mode 100644 Variables, Objects and Values/dictionaries.py
create mode 100644 Variables, Objects and Values/numbers.py
create mode 100644 Variables, Objects and Values/strings.py
create mode 100644 Variables, Objects and Values/understanding_basics.py
create mode 100644 classes/class-and-objects.py
create mode 100644 classes/compositions.py
create mode 100644 classes/decorators.py
create mode 100644 classes/fish.py
create mode 100644 classes/generators.py
create mode 100644 classes/inheritances.py
create mode 100644 classes/methods.py
create mode 100644 classes/object-data.py
create mode 100644 classes/object-dictionary.py
create mode 100644 classes/polymorphisms.py
create mode 100644 classes/primary-class-object.py
create mode 100644 containers/sequences.py
create mode 100644 exceptions/exceptions.py
create mode 100644 exceptions/generator_functions.py
create mode 100644 functions/defining_functions.py
create mode 100644 functions/generate-functions.py
create mode 100644 functions/listsofarguments.py
create mode 100644 functions/named-arguments.py
create mode 100644 functions/return-values.py
create mode 100644 modules/__pycache__/modules.cpython-34.pyc
create mode 100644 modules/modules.py
create mode 100644 primary/assigning_values.py
create mode 100644 primary/bitwise.py
create mode 100644 primary/conditionals.py
create mode 100644 primary/exceptions.py
create mode 100644 primary/file.txt
create mode 100644 primary/functions.py
create mode 100644 primary/main_script.py
create mode 100644 primary/object_variable.py
create mode 100644 primary/objects.py
create mode 100644 primary/regx.py
create mode 100644 primary/whitespaces.py
create mode 100644 regular expressions/reg
create mode 100644 regular expressions/regreplace.py
create mode 100644 regular expressions/regsearch.py
create mode 100644 regular expressions/reusereg.py
create mode 100644 strings/search.py
create mode 100644 strings/strings.txt
create mode 100644 strings/test.py
create mode 100644 test.py
create mode 100644 tests/boymeetsagirl.py
create mode 100644 tests/grtThingsDone.py
create mode 100644 tests/loops.py
create mode 100644 tests/recursion.py
create mode 100644 tests/test.py
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git remote add origin https://github.com/12reach/PlayWithPython.git
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git commit -m 'initial commit'
On branch master
nothing to commit, working directory clean
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git push origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
To https://github.com/12reach/PlayWithPython.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/12reach/PlayWithPython.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/12reach/PlayWithPython
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Merge made by the 'recursive' strategy.
first.py | 4 ++++
1 file changed, 4 insertions(+)
create mode 100644 first.py
hagudu@hagudu-H81M-S1:~/PlayWithPython$ sudo git push origin master
Username for 'https://github.com': 12reach
Password for 'https://12reach@github.com':
Counting objects: 114, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (110/110), done.
Writing objects: 100% (113/113), 35.01 KiB | 0 bytes/s, done.
Total 113 (delta 6), reused 0 (delta 0)
To https://github.com/12reach/PlayWithPython.git
6022f14..a6f48b2 master -> master
hagudu@hagudu-H81M-S1:~/PlayWithPython$

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s