Exporting a local EGit repo to local GitStack repo - eclipse

I've set up GitStack on my computer in order to be able to make builds of my application on various machines. My Eclipse project has a local git repo but I can't figure out how to connect the two.
The Team > Remote > Push and Team > Push to Upstream are unavailable (grey).
I've configured the following things and read this tutorial:
Git user name and email in Eclipse.
I've added a user and a repo in Gitstack.
I've also tried to click on my local git repo and do Paste Repository Path or URI and I manage to connect to my GitStack repo on localhost though its obviously empty. I suppose this is what I have to do on other machines to sync stuff?
How do I connect the two?
Here are my command line attempts (note: im using cygwin):
[~/eclipse/JfxMCApp]> git.exe remote add jfxmcapp.gitstack.local http://localhost/JfxMCApp.git
[~/eclipse/JfxMCApp]> git.exe remote -v
jfxmcapp.gitstack.local http://localhost/JfxMCApp.git (fetch)
jfxmcapp.gitstack.local http://localhost/JfxMCApp.git (push)
[~/eclipse/JfxMCApp]> git.exe push jfxmcapp.gitstack.local
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
After this Git just hangs for ages?
Update: it appeared in eclipse after adding it git remote add

First: try to use the git command-line client. Git is powerful and evil – and will not tell you any of it’s secrets if you hide it away behind GUIs.
About your question: Now that you set up your gitstack repo as a remote, all you need to do is push. If the push to upstream options are not available, try doing it from the command line: Run the git shell, go to your project dir and run git push.

Related

Connect to github server

I have the ip, useename and password of the github server, which uses gitlab, and I need to connect to it and manage files. What should I do?
I'm assuming you're asking how to manage/change files within a git repository. If you're asking something else, I've missed the point, apologies.
Firstly you will need 'git' on your local machine - install it with your package manager or download and install it from the git website.
Once git is installed you can clone a repository (which contains a set of files, and ends in .git) using the git clone command. Run git clone --help for more information on this, but if you already know the address of your git server and the path to the repository, it will look something like as follows:
git clone https://git-server.url/path/to/repo.git
Note that the URL you should use will depend on the configured transport protocol (git, ssh, http[s]) of your git server.
Next, you should makes some local configurations, for example, from a terminal:
git config user.name "your_username"
git config user.email "someone#example.com"
You can add --global to both of these command if you want these changes to persist outside of the current git repo.
Having a cloned repository automatically checks out an initial 'branch' on which you can make changes to files within your repository. See the git docs for a detailed explanation of a branch.
Files can be added, removed or renamed/moved using git add, git rm or git mv respectively.
Finally, you must commit your changes and push them
git commit -m "A message describing your changes"
git remote will confirm the name of the default remote (repo location). In this case, it is assumed to be origin. You can then push your changes to an existing branch (viewed using git branch -r), assumed to be master below:
git push origin master
Here you would be merging your master branch with the remote one. Clearly your permissions/project conventions will dictate what you can/should do to this repo.

In Eclipse java project, change git repository from an old one to a new one

I have a project in Eclipse that is associated with an old repository in Gitlab. The branch being used is called Test.
I created a new repository in Gitlab (and it only has the README.md file in it). It only has one branch: master.
I need to change the Eclipse project so that it no longer refers to the old repository (and old branch) but instead - refers to the new repository (with he master branch).
How can this be done?
TIA
Update
#Rizwan - thanks for the info. I did the following:
cd to the directory with the code
#initialize the repository
git init
#add reference to the repository I needed
git remote add origin "git#myrepo.com:WORK/<my-repository>.git"
#got what was currently in the repository
git pull origin master
#added code (not in the repository)
git add -A
#commit the code
git commit -m "first commit with code"
#sent it up
git push origin master
There was another message I used as a base (but I cant find it now)
TIA
We can directly perform this operation in Eclipse itself.
Goto - CurrentProject(Right Click) -> Team -> Remote -> Configure push to upstream -> Change(URI)
This might help
Locate your project on your local computer. You can do this by running:
cd /path/to/repo
Then check and confirm a list of all of your existing remotes. To do this run this command:
git remote -v
Change the URL of the remote with the git remote set-url command:
git remote set-url origin gitlab#gitlab.mydomain:root/testproject.git
Check back with the step 2 whether your repo has changed
Refresh/Clean Build your Eclipse project

C9 created workspace before repository

I made the mistake of creating a workspace before a repository on C9.io.
As a result I do not have version control. Naturally, I want to use Git for my project before make any more changes. Everything I have tried has failed. I would rather not have to copy all the code I've made into a new work space with an already set up repository. So if anyone has any suggestions or answers to this problem, via Command line, GUI or anything else that would be wonderful.
cloud9 doesn't do any special magic when cloning from a git repository, and you can add a remote the standard way you would do locally:
git init initialize a git repository in the current folder
git add -a add everything (or what you want)
git commit -m "initial commit" commit
git remote add origin git#github.com:<me>/<repo>.git add your repo
git push origin HEAD:master push HEAD to master branch in the remote you just added

Adding to Github from Visual Studio 2013 not working as documented

This is the online reference I am using. However when I enter the remote repository and hit publish I get an error
You cannot publish local branch master to the remote repository origin
because a branch with the same name already exists there. You might
want to rename your local branch and try again.
I dont want to rename anything as yet. I want the first version of the code to go into the master branch and at the same time create an upstream tracking branch locally.
Then I tried using the command line only. After creating a fresh repository, I ran the following commands
$ cd (project-directory)
$ git init
$ (add some files)
$ git add .
$ git commit -m 'Initial commit'
$ git remote add origin <url>
$ git push --force
This worked but now I have all my obj,bin,packages directories along with it. I don't want all those directories to go. Editing the git ignore did not help either. What I am doing wrong? Its taken more twice the amount of time to get the code into the repository than it has taken to write the code!
I only want my sources in the repository and have a tracking local branch to begin with.

Error pushing code to Github repository

I'm trying to setup jekyll by following this setup. For that I created a public repository and under the same name on my computer cloned the project.
However once I try and push the code, it gives me following error -
fatal: 'aniruddhabarapatre.github.com' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I tried doing Git setup in case something got overridden, but am unable to finish the process and it hangs on
git credential-osxkeychain
Make sure you are pushing to the right github repo.
Its url should be
https://github.com/aniruddhabarapatre/aniruddhabarapatre.github.com
If git remote -v doesn't show this, do a:
git remote set-url origin https://github.com/aniruddhabarapatre/aniruddhabarapatre.github.com
And try to push again.
For the credential issue, see this answer, or this one, or (for checking how git is installed) this answer.
When you create a git repository add git ignore files, then it no more push unwanted files
Git global ignore
errors like this will occur when you try to push to a GitHub which you did not connected with the local repository you have in your machine. We can resolve this in a such way!
One: Delete your local repository and clone your GitHub project to your local machine($git clone ..url..) and now you can push any change directly to your GitHub account. If you do not want the original file from your local machine because you have some code on it you can move that to some where other than the directory you going to clone it. Then paste the content of your change inside newly cloned folder. Some time the issue/error may still persist so lets move to the second option.
Two: Here you mostly play with GitHub and follow this instruction since I did this many times.
From your terminal
To initialize the local directory as a Git repository
$git init
Add the files to your new local repo
$git add .
commit the file
$git commit -m "any comment you want to say"
Add the URL for the remote(GitHub) repository
$git remote add origin ..url..
Set the new remote
$git remote -v
Push the change
$git push -u origin master
Now if you go to your GitHub repo you will see your change.
While pushing the terminal might say pull first bla bla ... in that case you can force your push by saying
"$git push -f origin master"!!
Hopefully this will be helpful.