Forums

Git push pythonanywhere project into github repository

Hi, as you said earlier, git commands are supported in the bash console. I want to upload my pythonanywhere project into the Github repository. In the bash console, I use this command but it throws an error.

(django2) 07:48 ~/mysite $ git remote add origin https://github.com/souravdaswebclip/webclipofficial.git
fatal: Not a git repository (or any parent up to mount point /home/neso)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
(django2) 07:50 ~/mysite $

What am I missing?

You need to initialize the git repo first with git init.

Its throwing another error

(django2) 14:36 ~/mysite $ git commit -m "first commit"

 *** 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.

 fatal: empty ident name (for <neso@4261811f904c>) not allowed

You need to set your identity as described in the message.

How? Please explain with a sample command!

Sample commands are shown in the message that you pasted:

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

You should replace the strings with your chosen email and name. You can omit --global option if you want to set up git only for the current project you're working in.

another error raised

(django2) 14:29 ~/mysite $ git config --global
usage: git config [<options>]
 Config file location
--global              use global config file
--system              use system config file
--local               use repository config file
-f, --file <file>     use given config file
--blob <blob-id>      read config from given blob object
Action
--get                 get value: name [value-regex]
--get-all             get all values: key [value-regex]
--get-regexp          get values for regexp: name-regex [value-regex]
--get-urlmatch        get value specific for the URL: section[.var] URL
--replace-all         replace all matching variables: name value [value_regex]
--add                 add a new variable: name value
--unset               remove a variable: name [value-regex]
--unset-all           remove all matches: name [value-regex]
--rename-section      rename section: old-name new-name
--remove-section      remove a section: name
-l, --list            list all
-e, --edit            open an editor
--get-color           find the color configured: slot [default]
--get-colorbool       find the color setting: slot [stdout-is-tty]

 Type
--bool                value is "true" or "false"
--int                 value is decimal number
--bool-or-int         value is --bool or --int
--path                value is a path (file or directory name)

Other
-z, --null            terminate values with NUL byte
--name-only           show variable names only
--includes            respect include directives on lookup

(django2) 14:30 ~/mysite $ git branch -M main
error: refname refs/heads/master not found
fatal: Branch rename failed

After omit --global I use git branch -M main command and its throwing this error.

You need to run the full commands that @pafk provided, replacing you@example.com with your email address and Your Name with your actual name.

Did that and getting this error?

(django2) 19:15 ~/mysite $ git commit -m "first commit"
 On branch master

 Initial commit

  Untracked files:
         accounts/
         blog/
         chatclip/
         db.json
         db.sqlite3
         hashtags/
         manage.py
         mysite/
         static/
         stories/
         users/

  nothing added to commit but untracked files present
 (django2) 19:20 ~/mysite $ git branch -M main
  error: refname refs/heads/master not found
  fatal: Branch rename failed                                                                   
  (django2) 19:15 ~/mysite $ git branch -M main
  error: refname refs/heads/master not found
   fatal: Branch rename failed
   (django2) 19:15 ~/mysite $

its says branch rename failed!

You tried to branch off of something that does not exist yet. Your first commit committed nothing and git is smart enough that it doesn't create an empty commit when you do that.

I have to git ignore for that?

No, you need to add files to a commit so that, when you commit, there are changes in the commit.

Which command i use for that?

Add the files which current changes you want to track in the commit with git add <path>, next commit those files with git commit, then you should be able to rename the branch you're working on.

Finally, it's working. Thanks, you were right. It's done.

Glad to hear that!