I am quite new to Git/Github. I am trying to upload my program / website to Github, so I can upload it to Heroku.
I tried a ton of different things, and I am stuck with this for over a week... As far as I know the way to do it is:
git init
git add .
git commit -m 'initial commit
the result I get is:
git init
> Reinitialized existing Git repository in /Users/username/test/website/.git/
git add .
> error: 'website/' does not have a commit checked out fatal: adding files failed
git commit -m 'initial commit
>
Untracked files:
(use "git add <file>..." to include in what will be committed)
website/
nothing added to commit but untracked files present (use "git add" to track)
What else can I do to set my website to Github?
CodePudding user response:
If you already have a local git repository on your computer you need to set the remotes to the remote git repository such as:
git remote add origin <link here>
Then you need to stage the changes:
git add .
git commit -m "Initial commit"
git push
CodePudding user response:
"Reinitialized existing Git repository in /Users/username/test/website/.git/",
It looks like you already have a local git repository on your computer. Next step is to create repository in the github, get the https link and do
git remote add origin <your repository https url>
git add .
git commit -m "intializing project"
git push origin <your branch name, ex. master>
CodePudding user response:
First remove .git
directory in the website
folder. Then try again.
CodePudding user response:
- First log in to GitHub and create a repository with the same name as what you want to push in Github. Repository name = Project name.
- Then go to the terminal of your project, cd (your project name) and run the following command one by one.[seems you are not at the root of your project]
echo "# (your project name)" >> README.md
git init
git add README.md
git commit -m "first commit"
... ...
git remote add origin https://github.com/Here will be your github acc. name/(Your Repository name = Project name). git
git push -u origin main
- If you clone from another repo then instead of
remote add origin
remote set-url
https.. do rest as usual.