I have a website I'm developing, it's github is https://github.com/samclark2015/Project-Emerald. I have the repo under my user folder in a subdirectory. Now when I push the site to github, it updates the tree as Sites/Project Emerald/... I need the contents of the project emerald folder in the root of my github repo. How can I change the root of my repo on my PC?
Since you just did your first commit in your GitHub repo, the easiest way would be to:
delete your local .git directory you have under 'Site'
recreate your repo locally, and force push it:
That would give:
# in Site/Project-Emerald
git init .
git add remote origin https://samclark2015#github.com/samclark2015/Project-Emerald.git
git add .
git commit -m "first commit, again"
git push -force origin master
You would then see in your GitHub repo directly:
PHP
SpryAssets
pictures
README
config.inc
...
Other alternatives are mentioned in "My Git repository is in the wrong root directory. Can I move it? (../ instead of ./)"
Related
In Github, i have already a repository, e.g. called "java8"
And under it, i would like to have a sub-folder, e.g. called "01-lambda"
So my folder structure in github should be
java8
01-lambda
02-enums
etc.
Then I want to commit my code to the sub-folder "01-lambda"
How can I do that?
What I tried:
I just created a new folder with a txt file "01-lambda" under the repository "java8", then I tried to commit, but git bash shows they cannot find the sub-file.
I just commit my code directly to repository "java8", but then I need to change path of every files, and add /01-lambda in the path
git init
git add *
git commit -m “my first repo”
git remote add github .git
git remote -v
git push -f github master
I just created a new folder with a txt file "01-lambda" under the repository "java8", then i tried to commit, but git bash shows they cannot find the sub-file.
You need to add before committing, assuming you do have a file inside the new folder (Git would not add just a folder):
git add 01-lambda
git commit -m "add 01-lambda"
I have files for a website in a folder on my computer that I'd like to put on GitHub. Do I create a repository in GitHub Desktop first or create a repository on GitHub first? And once I have a repository what is the very first thing I do to move those files into the repository? This may be a stupid question but I've made a mess of things and I'm very confused at this point.
Create a repository on GitHub
git clone your new repository on your computer
Copy the files you want to push to your repository inside the new folder created by cloning
git add --all to add all these files for commit
git commit -m "Initial commit" to create a commit
git push to push this commit to your GitHub repository
I have a project in Eclipse that I want to put on github, so I went to github and created the repos for them, but I want to clone them right into the folder where the files are stored in my eclipse workspace. How can I do this?
EDIT: When I try it, the github app says it can't clone because the folder isn't empty.
EDIT 2: Will this work? Changing the name in eclipse to rename the project folder, then cloning the repo to the name I want, in the workspace, then renaming the eclipse project so they merge and I can commit the new files.
GitHub has a guide explaining how to put an existing project on GitHub.
You should not clone the repository, but add the GitHub repository as a remote to a local repository you create yourself.
Go to your project folder and initialize a local repository with git init
Add and commit all your project files to the local repository. (e.g. git add . and git commit -m "message")
Add the GitHub repository as a remote. git remote add origin *github repository URL* (Verify with git remote -v)
Push your project to GitHub with git push origin master.
If you already have committed files to the GitHub repository, it is still possible.
Initialize your local repository.
Add GitHub as the remote.
Pull from GitHub.
Add and commit your project.
Push you project to GitHub
First add the remote as follows
git remote add origin <GIT URL>
Then simply do the following (MAke sure to commit any of your local files)
git pull --allow-unrelated-histories
I have repository in GitHub. I edited files in my PC, committed them and now I want to push these files to GitHub. How can I do it?
If the files are already cloned from a github repository git push will do it.
cd /path/to/repo
git push
If this local repo does not belong to any github repo, create a repository in github. This will give you a git repo url like git://github.com/username/project.git. Now you need to add this url as remote to your existing local repository
cd /path/to/repo
git remote add origin git://github.com/username/project.git
Then you can commit your changes and push it
git push
Go to github and create a repository under your account (if you haven't already). If you've done that, follow the instructions for pushing code from an already existing repository.
I created a github new repository first in github webpage and then I opened Git Bash to upload folders to this repository. I first used $cd f: and $ git clone git#github.com:username/project name.git to create a folder(with a initial .git folder and a README file in it) in f disk. Then, I used $cd f:\project name to switch to the current folder. After that, I copied all my project folders to my project name folder in f disk. Finally, I used the following four lines to upload all my project folders to github:
$git add .
$git remote rm origin
$git remote add origin git#github.com:username/project name.git
$git push -u origin master
After I entered the passphrase, Git Bash just showed everything up-to-date. But I refreshed my github repository page, there is nothing but the initial README file. Could someone tell me what the matter is?
You didn't commit after your git add.
git commit -m "first commit"
That is why git considered there was nothing to push: you HEAD was still the same than your remote origin cloned repo.
See Git Basics:
Your git add updating the staging area (index), but only a git commit will update your git directory.