Importing GitHub repository into a specific folder - github

I have a GitHub repository that I've created by copying content of a specific folder.
Now I have installed GitHub Desktop and I would like to directly connect this directory to my GitHub repository instead of re-downloading and creating a copy.
How can I do this?

Before switching to GitHub Desktop, you should prepare the environment for that folder, in order to be linked to the remote repository:
cd /local/path/to/folder
git init .
git remote add origin https://github.com/<me>/<myRepo>
git fetch
git switch -m master
Then you can open GitHub Desktop and add a local repository (the folder you just configured)

Related

Jmeter integration with Git Hub ( How to push/Pull jmx,parameter files to Git)

Need to Save Jmeter JMX/data files to github from Jmeter. How to point jmeter datafiles/parameter files to GIT files. While running the test jmeter need to pull latest datafiles from GIT
I downloaded GitHub Desktop from here.
Link your GitHub account and then create or clone a repo.
Then any files edited within that directory will be recognised and can be pushed to GitHub, including jmx files.
Can also easily add files/folders/results/HTMLreports etc easily from your local machine.
You can upload an existing file to a GitHub repository using the command line.
Copy the JMX\data files you'd like to push to GitHub into the local directory that was cloned from the repository.
Run Git Bash.
Change the working directory to your local repository.
Add files to commit in your local repo:
git add test.jmx
Commit files to your local repo:
git commit -m 'Some comment text'
Push your files from local repo to GitHub
git push origin your-branch-name

Update a GitHub repository without cloning

Here's the situation, we are currently working on a project and lately we decided to upload it on GitHub. Now I made my changes and I want to push the changes onto the repository.
As far as I read, in order to make changes you need to clone the repository but that will download all files from the repository and I already have all of the source files.
I'm using GitHub desktop and I can't find any option to clone without downloading and update or create branches from my existing files. Creating a local one is an option but it needs to be uploaded as a separate repository instead of linking it to a current one.
Is there any way to push updates, create branches to the repository from my local project to an existing repository?
Your local project should already be a git repo, if you uploaded it to GitHub.
But in case it is not, switch to command-line, and do inside the root folder of your project (which should shows the same files as your remote repo):
git init .
git remote add origin https://github.com/<user>/<project>
git fetch
The fetch part will download the repo but leave your files alone.
(But do a backup still, just to be safe)
git branch master origin/master
git reset master
From there, your GitHub Desktop should show you any diff between your files and what was fetched from the repo.

Cloning a github repo into an existing project?

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

How to push code to root of git repository (GitHub)

I am very new to git and have been facing the problem below for 4-5 days now.
I have a project that I want to share on GitHub and I created a repo (https://github.com/jitix/cfs/tree/master/cfs) for the same.
Here is what I did:
Checked out the code from svn using Eclipse (Juno).
Removed svn related files and 'cleaned' the folder by doing Team > Disconnect.
Created a local git repository (using both via eclipse and cli on different occasions).
Added appropriate .gitignore file.
Committed the code into the local repo (somehow eclipse moves the folder there, but not an issue). Eclipse made me choose the $repo/cfs as the folder where the code is committed. I could not commit it to $repo.
Now I want to push it into GitHub. Tried out the following:
Method 1 (eclipse):
Team > Remote > Push
Use refs/heads/master as both source ref and dest ref and commit.
Method 2 (cli from the $repo/cfs directory):
git remote add origin jitix#https://github.com/jitix/cfs.git
git push -u origin master
Issue:
In both cases, I am getting the cfs directory under the GitHub repo, not at the root (as most projects have). Also, each folder has a .. link to the parent folder in it (something that I have never seen on GitHub, and something that does not happen if I push using svn).
I checked out my code from svn, created a local repo and committed the code into
You need to create the git repository inside the folder that you want to upload. You've created it one level above the cfs folder and then pushed that, you want to run git init while inside cfs and then go from there.
Try in commandline instead using eclipse and follow the steps that GitHub recommends.
Go inside the directory of your project and type:
git init
git commit -a -m "first commit"
git remote add origin jitix#https://github.com/jitix/cfs.git
git push -u origin master
It should work, although is pretty much what you were doing.

How to sync folder in the web server with local git repo in Eclipse?

I am trying to configure Git in Eclipse Kepler and sync my local git repo with a folder in the local web server.
The project folder in my local git repo is located at C:\Users\MYPC\git\mod_helloworld.
My web server files are located at D:\Install\xampp\htdocs\joomla\modules\mod_helloworld.
Basically I will be working directly on the web sever files and would like to sync the mod_helloworld folder with the local git repo. I could not find an option to do this in Eclipse's Git Repositories.
If you're looking to have D:\Install\xampp\htdocs\joomla\modules\mod_helloworld be an exact copy of C:\Users\MYPC\git\mod_helloworld then you could look into setting up a junction link.
The command to do so is:
mklink /j D:\Install\xampp\htdocs\joomla\modules\mod_helloworld C:\Users\MYPC\git\mod_helloworld
I would suggest trying this out with a temporary folder to see how it works with:
mklink /j D:\Install\linked_folder C:\Users\MYPC\git\mod_helloworld
By creating a junction this way all requests to D:\Install\linked_folder will actually be sent to C:\Users\MYPC\git but D:\Install\linked_folder will behave as a normal folder.
However, you should be careful as this means that any changes within C:\Users\MYPC\git\mod_helloworld would be reflected within the linked folder so if you checkout a development branch, the server folder would be serving up your development branch files until you checked out the stable release branch (assuming master) again.
As this is not ideal for you, you can make your C:\Users\MYPC\git\mod_helloworld folder into a bare repo from which you would add as a remote source for your D:\Install\...\mod_helloworld repository such as:
cd C:\Users\MYPC\git
mv ./mod_helloworld ./mod_helloworld_backup
mkdir mod_helloworld
cd mod_helloworld
git init --bare
cd D:\Install\xampp\htdocs\joomla\modules\mod_helloworld
git init
git add -A
git commit -m "commiting all server files to server repo"
git remote add folder file:///C:/Users/MYPC/git/mod_helloworld
git push folder master
You can work on your server files directly now as your 'local' repo while being able to then commit/push to 'remote' which is, in fact, C:\Users\MYPC\git\mod_helloworld