Whats the most easiest way to create a repository for my local Java Eclipse Projects?
Currently I create a Repo on GitLab an clone it. Then i move the .git folder to the new Empty Eclipse Project. then add, commit and push all. Its so annoying.
Isnt there an easier way to do this?
I've already searched for it, but i can't find anything out about an easier way.
just try below command in your root project
git init
git add .
git commit -m 'your commit'
git remote add origin <git url> // <git url>: git#mygitLab.com:test.git
git push -u -f origin master
Related
I have been creating some repositories of my projects since the terminal and everything was good, but recently I tried to push a project to GitHub and but another folders are created.
For example, the path of my project folder is /Desktop/Programming_course/React_Native/robotreact.
So, since the terminal I go to the path of my Project robotreact and I run:
git add .
git commit -m "first commit"
Then, in GitHub, I create my repository and after that I run:
git remote add origin https://github.com/Josesosa0777/robotreact.git
when I push it running: git push -u origin main
In my GitHub are created other folders:
How can I avoid those extra folders?
It seems like if another project is added, I am not sure if the problem is about a SSH key, I dont know how to solve it, any idea?
That means you have initialized your Git repository in / instead of /Desktop/Programming_course/React_Native/robotreact: check for /.git
If that is the case, and you don't have many commits, you can simply:
delete /.git
initialize the repository in the right folder,
add the remote origin
add files, commit and push
That is:
cd /Desktop/Programming_course/React_Native/robotreact
git init .
git remote add origin https://github.com/Josesosa0777/robotreact.git
# check your user.name/user.email
git config user.name
git config user.email
git add .
git commit -m "First import"
git push -u origin main
If your local branch is master:
git push -u origin master:main
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
I need to export an Eclipse project to GitHub. I am using Eclipse-Mars with the eGit plugin. I have spent hours reading documentation, tutorials, and posts and see that there are basically two ways
Create an Eclipse project and a local Git repository. Commit to local repository. Create a repository on GitHub. Push the Eclipse project to the repository on GitHub. When I try this, I get the error "rejected non-fast-forward". I have no idea why. I did create a .gitignore on GitHub when I created the repository - is that causing a problem?
Create a repository on GitHub. In Eclipse, clone this repository and then add files. Commit to local repository, then push. This works, but I end up with a weird configuration on GitHub:
reponame/myprojname/src
when I would prefer the more normal
reponame/src
Which method is the correct way to proceed? Why do I get the push error in the first method, and why the strange folder layout in the second?
You first need to pull the github code into you local machine.
=> git remote add origin
=> git pull origin master
will automatically fetch and merge the github repo with your local copy. You may need to resolve some conflicts that could be generated due to 3-way merge.
After all this, you can use -
=> git push -u origin master
For the second Point,
If you want src/ directory directly under reponame/ on github, then you should execute git clone after creating the project in eclipse and git clone should be executed inside the myprojectname/ directory.
When you created the .gitignore file on GitHub, you created a commit in the repository that isn't in your local copy. You'll need to add the GitHub repo as a remote, pull the change, and then push your local changes:
git remote add origin <path to your repository>
git pull origin master
git push -u origin master
Hello I want to use github but I have no clue how to use it. I read the tutorial but I still can't figure it out.
What I want is that i can push my project from my xampp localhost to github.
How can I do that?
Thanks for responding
You can create a new Repository : https://github.com/new
and
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/yourPseudo/repositoryName.git
git push -u origin master
Assuming you use windows: You can install the following tool from Github-for-Windows. It is really easy to use and you can upload your local project easily with the tool set up.
#bouffe Basically said all you need to say.
I find it easier to create a repo in github first, check the box for "add a readme" and then once you have a page, just do a git clone in your local environment. That way you can just type in git clone https://github.com/yourPseudo/repositoryName.git which you can copy and paste.
That saves time. Also, if you use VS code you don't even need to do the commit -m anymore. Just save your changes and then click on the dev tools on the left and it will add and commit all new files. Makes it much easier.
Make sure you do a git checkout -b "dev" once you set up a repo. NEVER CODE ON THE MASTER.
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