I have code in Eclipse that I'd like to upload to GitHub but so far I can't figure out how. It says "create a repository" but that looks more like a folder that holds your projects and I'm not sure how to upload my code to it. Apologies for the seemingly dumb question. Also, how does one delete repositories? Didn't see a way to do that either.
While the EGit plugin for Eclipse is a good option, an even better one would be to learn to use git bash -- i.e., git from the command line. It isn't terribly difficult to learn the very basics of git, and it is often very beneficial to understand some basic operations before relying on a GUI to do it for you. But to answer your question:
First things first, download git from http://git-scm.com/. Then go to http://github.com/ and create an account and repository.
On your machine, first you will need to navigate to the project folder using git bash. When you get there you do:
git init
which initiates a new git repository in that directory.
When you've done that, you need to register that new repo with a remote (where you'll upload -- push -- your files to), which in this case will be github. This assumes you have already created a github repository. You'll get the correct URL from your repo in GitHub.
git remote add origin https://github.com/[username]/[reponame].git
You need to add you existing files to your local commit:
git add . # this adds all the files
Then you need to make an initial commit, so you do:
git commit -a -m "Initial commit" # this stages your files locally for commit.
# they haven't actually been pushed yet
Now you've created a commit in your local repo, but not in the remote one. To put it on the remote, you do the second line you posted:
git push -u origin --all
Here is a step by step video of uploading eclipse projects to github
https://www.youtube.com/watch?v=BH4OqYHoHC0
Adding the Steps here.
Right click on your eclipse project -> Team -> Share project
Choose git from the list shown; check the box asking create or use repository -> click on create repository and click finish. - This will create a local git repo. (Assuming you already have git installed )
Right click on project -> Team -> Commit - Select only the files you want to commit and click on Commit. - Now the files are committed to your local repo.
Go to git repositories view in eclipse ( or Team -> Show in repositories View)
Expand the git repo of your project and Right click on Remotes -> Create Remote
Remote name will appear as origin, select 'Configure Push' Option and click ok
In the next dialog, click on change next to URI textbox and give your git url, username, password and click on 'Save and Push'. This configures git Push.
For configuring Fetch, go to Git Repositories -> Remote -> Configure Fetch -> Add -> Master Branch -> Next -> Finish -> Save and Fetch
For configuring Master Branch, Branch -> Local -> Master Branch -> Right click and configure branch -> Remote: origin and Upstream Branch : refs/heads/master -> click ok
On refreshing your repo, you will be able to see the files you committed and you can do push and pull from repo.
You need a git client to upload your project to git servers. For eclipse EGIT is a nice plugin to use GIT.
to learn the basic of git , see here // i think you should have the basic first
For eclipse i think EGIT is the best option.
This guide http://rogerdudler.github.io/git-guide/index.html will help you understand git quick.
Many of these answers mention how to share the project on Git, which is easy, you just share the code on git, but one thing to take note of is that there is no apparent "project file" that the end user can double click on. Instead you have to use Import->General->Existing project and select the whole folder
Jokab's answer helped me a lot but in my case I could not push to github until I logged in my github account to my git bash so i ran the following commands
git config credential.helper store
then
git push http://github.com/[user name]/[repo name].git
After the second command a GUI window appeared, I provided my login credentials and it worked for me.
Related
I have a Maven project where I use buildnumber-maven-plugin for incrementing the build number. After each "mvn package" command, a variable inside buildnumber.properties file is incremented to keep tracking of current build number.
Is there a way in Bitbucket Pipelines after I run the job with "mvn package" command to commit/push the changes made by buildnumber-maven-plugin in that file? Of course, this question makes sens if running a command in butbucket pipeline can change files inside the repository.
If any users with access to the repo are able to push to the branch you would like to commit to, you are able to commit that file back to your repository as outlined here: https://community.atlassian.com/t5/Bitbucket-Pipelines-articles/Pushing-back-to-your-repository/ba-p/958407. Ensure to add [skip ci] so you don't create a new pipelines build for that new version bump commit.
If pushing to the branch is restricted, you can use one of these methods: https://confluence.atlassian.com/bitbucket/push-back-to-your-repository-962352710.html. However, this will require providing a single user with permission to push to the branch.
I have a local workspace which I want to save in git, this wasnt a local git repo until now.Just workspace
The steps I did in git bash
cd myworkspace
git init
git add .
git commit -m "First commit"
git remote add origin https://github.com/username/eclipse.git
git push origin master
By doing this I got an error
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/username/eclipse.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
then I did this
git pull origin master
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/koushikpaul1/eclipse
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
fatal: refusing to merge unrelated histories
Anyone can help me with this error ,
Note : I created my git repo as a java one so currently it has only
.gitignore and README.md
while googling I found the steps to check in an existing workspace into git are
$ cd my_project
$ git init
$ git add *
$ git commit -m "First commit"
$ git remote add origin https://github.com/yourname/my_project.git
$ git pull origin master
$ git push origin master
But I am stuck at the second last step.
Many Thanks !
The issue here is you already init repository on your local workspace which already contain some files. When you create repository on GitHub and init it with .gitignore and README.md it also contain some files.
When you push your project git will reject because it does not know how to merge your content.
Here are solutions
Use git push -f which will push all your local repository to remote repository but this will also replace .gitignore and README.md, then you can them manually later.
Delete your remote git repository and reinit it as bare repository (do not check init with .gitignore, README.md) then try to push again.
Just clone remote repository to your local workspace then manually add your files to the cloned repository
For more info visit:
https://help.github.com/articles/creating-a-new-repository/
See number 5.
There are a number of optional items you can pre-populate your
repository with. If you're importing an existing repository to GitHub,
don't choose any of these options, as you may introduce a merge
conflict. You can choose to add these files from the command line
later.
You can create a README, which is a document describing your project.
You can create a .gitignore file, which is a set of ignore rules.
You can choose to add a software license for your project.
Hi i am using jenkins and bitbucket , i want to trigger a build in jenkins when ever i commit any thing to bitbucket repository .
in jenkins
i created a project called test_1
in configure section Build Triggers part i ticked Trigger builds remotely
i added a token TEST_TOKEN
when i type this in my browser url and execute the jenkins build is triggered
http://test.com:8080/job/test_1//build?token=TEST_TOKEN
In bitbucket
i added a jenkins hook
Endpoint : http://test.com:8080/job/test_1//build?token=TEST_TOKEN
Module name - empty
Project name - test_1
Token - empty
then commited some code to bitbucket via git , The jenkins build not running , seems that the trigger is not running . :/ how to solve this problem . please help me . thanks in advance :)
I had the same problem. #fmitchell is correct with his suggestions for these fields.
But it didn't work for me.
I use a normal POST Hook instead where I provide the whole URL:
http://USER_NAME:USER_TOKEN#YOUR.JENKINS.URL.COM:YOUR_PORT/job/YOUR_PROJECT_NAME/build?token=some_token_from_jenkins
eg: http://bob.miller#jenkins.example.com:8080/job/test_1/build?token=TEST_TOKEN
It seems to be that Bitbuckt is missing the last parameter "build" in its created URL, but I can't tell for sure.
------Update------
I found a better solution, where you don't only trigger your build but also be able do build different branches by different Jenkins projects:
Install Bitbucket Plugin at your Jenkins
Add a normal Post as Hook to your Bitbucket repository (Settings -> Hooks) and use following url:
https://YOUR.JENKINS.SERVER:PORT/bitbucket-hook
Configure your Jenkins project as follows:
under build trigger enable Build when a change is pushed to BitBucket
under Source Code Management select GIT; enter your credentials and define Branches to build (like **feature/*)
By this way I have three build projects, one for all features, one for develop and one for release branch.
And best of it, you don't have to ad new hooks for new Jenkins projects.
It should be:
Endpoint : http://test.com:8080/
Module name:
Project name: test_1
Token: TEST_TOKEN
I have a new project in Eclipse in the directory ProjectDirectory which contains the src, lib, etc. folders. Note that this project has never before communicated with any repository.
I have a git repository https://github.com/myrepo/mygit.git with a username user and a password pass (note that this is fake info). In that repository, I currently have some files.
I want to do the following.
Remove ALL the current contents in the git repository
Add the new contents from my Eclipse project into this repository. This should result in no conflicts or no errors whatsoever, since I want to completely replace the current repository with these files.
With specific instructions, what set of commands in the terminal would I write to accomplish this?
Its fully simple. First go into the directory in terminal where the eclipse project is.
To start putting this under version managment:
git init
Then add the origin as the git repo ( copy your ssh read+write access from github, this you see when you are loggin in on github and navigates to the actual repositorys directory ):
git remote add origin <copied_adress_from_github>
So now in the last step you will need to overwrite forced the remote repo with:
git push -f origin master
You can start commiting, making branches etc... However if on the remote repo there was other branches you want to remove them with:
git push origin --delete <branch_name>
I have a situation where I have an elderly CVS repository which we would like to convert to git once and for all while keeping full history etc.
All folders at the root of the repository contains Eclipse projects (either plain or dynamic web projects) including .classpath and .project. We use Team ProjectSets to check out the projects we need for a given task (where the project set is located in the project containing the main, and the rest are library projects).
When the Team ProjectSet is checked out, the workspace is fully populated.
This approach has worked pretty well for many years (except the project set part which came with 3.5), and we would like to work in a similar way with git if possible, but we are uncertain how.
I've played somewhat with git cvs import but it failed - probably due to us not using modules.
How would you suggest we do this, and how should we work with git to allow our current usage of shared library projects? Would we HAVE to introduce maven and create maven modules for our library projects? Or just ant ivy?
EDIT: I've now managed to convert our CVS repository to Subversion with a suitable cvs2svn invocation and found that Eclipse recognizes the resulting Subversion repository nicely. Unfortunately after cloning http://github.com/iteman/svn2git` and trying to run bin/svn2git I get
tra#Sandbox:~/cvsgit/svn2git/svn2git$ bin/svn2git
bin/svn2git:35:in `initialize': wrong number of arguments (2 for 1) (ArgumentError)
from bin/svn2git:35:in `new'
from bin/svn2git:35
This is with Ubuntu 10.04.1 LTS Server and I've tried various sudo things with Ruby and its gems without fully understanding what I did as I am not a Ruby programmer so I may have messed up things a bit. I'd appreciate advice - if the easiest is to install another Linux variant to do the conversion, that is fine.
EDIT:
https://help.ubuntu.com/community/Git
http://css.dzone.com/articles/subversion-git-morning
Edit: My first try with the default svn2git completed successfully (after a while), and I get a nice repository where git branch -a reports roughly
tra#Sandbox:~/gitroot/svnroot$ git branch -a
* master
remotes/XX64_DEPLOYED_CODE
remotes/Beta1
remotes/Beta2
remotes/SV46
... lots more
We are interested in being able to check out the SV46 branch and work with it (we basically do not care about the tags, just actual branches). I have set up gitosis and pushed this repository to gitosis, and cloned it to another computer to find out how to do the "work with SV46" bit with Eclipse. THAT repository does not know of all the branches:
tra#TRA ~/git/git00 (master)
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
Do I need to massage the original result from svn2git to get the information into the gitosis repository? Do I need to clone with an argument? Should I redo the svn2git step with the suggested version instead of the one shipping with Ubuntu?
EDIT: It turned out that publishing the svn2git generated repository with "git push --mirror" made things shown up in the gitosis repository. I now see the following inside gitosis (trimmed):
tra#Sandbox:/srv/gitosis/repositories/git01.git$ git branch -a
* master
remotes/XX64_DEPLOYED_CODE
remotes/Basic_Beta1
remotes/Beta1
remotes/Beta2
remotes/SV46
... lots more
tra#Sandbox:/srv/gitosis/repositories/git01.git$ git branch
* master
tra#Sandbox:/srv/gitosis/repositories/git01.git$ git tag -l
tra#Sandbox:/srv/gitosis/repositories/git01.git$
Trying to clone this repository with git clone gitosis#sandbox:git01 -b remotes/SV46 or git clone gitosis#sandbox:git01 -b SV46 both tell me that the remote branch is not found upstream origin, using HEAD instead.
Am I barking up the wrong tree?
First of all, using submodules for independent parts of your Central VCS repository (i.e. your CVS repo) is always good (see "What are the Git limits?").
That mean you will end up with many independent Git repo, that is "set of files evolving independently one from another", which is why submodules exist.
So multiple Git import (in multiple repo) are required.
But since git cvs import is not always up to the task, I would recommend:
cvs2svn in order to get an SVN repo first (just one repo)
svn2git in order to properly convert your SVN repo to a git one (i.e. transforming SVN branches into Git branch and SVN tags into Git tags)