Git creating directory in repository [Codespaces] - eclipse

My Setup: I do the local commits in Eclipse IDE itself. My local repositories resides within the workspace as well.
Somehow I couldn't do remote commits using Eclipse so I just did, thus I've been using git bash to do remote commits to codespaces.com
git remote add origin git#codespaces.com:acct_name/repo_name
git push origin master
This has served me well so far.
Now I created another repository, let's say repo_foo.
For this repository, I want to place multiple directories(projects) inside it. I don't really need the codespaces Projects here.
I just want to be able to do this.
git remote add origin git#codespaces.com:acct_name/repo_foo/proj_1
(currently this gives no repository in path error)
So the repo structure should looks like this.
repo_foo
- proj_1
-src
- proj_2
-src
-lib
etc.
Any ideas for this?

Now I created another repository,let's say repo_foo. For this repository, I want to place multiple directories (projects) inside it.
I dont really need the codespaces "Projects" here. I just want to be
able to do this.
So you want to have nested git repositories in other git repositories? It’s unclear what your final goal is. Perhaps git submodules would serve your needs? Submodules are basically other repositories cloned into another git repository. So let’s say you have a main project, but you also have a repo for a great library you want to use. You can add the library as a submodule & refer it to the main project. That way if you make changes to the library, the projects that have that library as a submodule can be automagically updated. Quite powerful concept if you need that.
The problem from my perspective is you are convolving the concept of a directory & a repository into one thing. So when you do the following:
git remote add origin git#codespaces.com:acct_name/repo_foo/proj_1
You are saying, “Go into this repo. And create another repo in that repo.”
There will be no origin of git#codespaces.com:acct_name/repo_foo/proj_1 since the parent repo of git#codespaces.com:acct_name/repo_foo already exists.
What you need to do is setup a repo for each project & decide on a naming scheme. Something like:
repo_foo_proj_1
repo_foo_proj_2
etc…
And your git remote add origin command would be:
git remote add origin git#codespaces.com:acct_name/repo_foo_proj_1
git remote add origin git#codespaces.com:acct_name/repo_foo_proj_2
etc…

When you initialize git in a folder, all the sub folders are auto tracked. When working with multiple projects or folders, where each should be tracked independently. You should keep them at the same level.
--home
--Workspace
--project1
--project2
--project3
In case you initialize git accidently at workspace, when you check git status, it includes all the the files and folders underneath to be tracked. When you perform git remote add origin, config file under .git/config is added with a remote url which is used for push and pull operations. So if you initialize repo_foo and provide the remote add, you cannot perform the same actions under proj_1. It's automatically being tracked and all the push/pull operations will use the path present in repo_foo/.git/config file.

Related

what Git Ignore field means in github desktop while creating a new repository

see the Git Ignore option in the below image.What I have to choose, I am creating an ionic-framework repository.
https://i.stack.imgur.com/pBvkd.png
.gitignore is a file which, Git uses to determine which files and directories to ignore, before you make a commit. These files/directories will not be pushed into the repository.
If you have any files or directories that don't need to be pushed into the repository, then you can include them. (a simple example : log files)
If there is no ionic option, you can ignore it, and create it locally on your repo, then push it back to your GitHub repo.
To create it, see https://www.gitignore.io/api/ionic3
It does generate an Ionic .gitignore for you.

Can I create local version of .gitignore that applies only to my local repository?

There are some files/directories in the remote git repository for my project that I don't want in my local repository. They are useful to other project members, but not me. And I can't just identify them in the root .gitignore file because when that file becomes part of the remote repository it becomes the rule for everybody else so they change it back. We don't want to get into a .gitignore war.
Is there a straightforward way for me alone to selectively chose the files/directories that I do or don't want to exchange between the remote repository and my local repository when I do a 'git pull'? To be clear, I'd like to make my selections once and have them take effect every time I do a 'git pull' (or equivalent) and not force them on anyone else.
You can add .gitignore to your .gitignore file.
You then git rm .gitignore and it is no longer tracked.
Then just remove the other files you don't want tracked.

push specific files using egit

I thought this would be a no pbrainer, but for some reason can't find anything on the issue - is there a way to push only specific files from egit? Our repository contains a lrage number of files which are mainly of no interest to me, and every time I try to push I get many DIRTY_TREE errors in files I don't care about. Right-clicking on a file and then attempting push, just tryes to push the entire repository
I'm using Eclipse Juno from mac, and BitBucket repository
Thanks!
Git push deals with commit objects, not with files. If you want to push specific files, you have to make a commit that contains only those files. In your case, you might want to look at the git update-index --assume-unchanged <files> command, or at the .git/info/exclude file, which is like .gitignore except it's for your local repository only (doesn't get shared with the upstream repo).

How to check out a project from a server with Git

You may classify my question to the layman's level, but I am using Git for the first time (til now I used TortoiseSVN) and I am not sure how I can check out an existing project from a server, so as to have it available on my local machine in a folder. I have installed Git Bash. Should I run it (Gui), select New Archiv and then specify the path of the project in the server? Is there a better Git framework to install, which is appropriate to make the same task more easily?
I would appreciate also some screenshots if needed in the answers.
Update: I have installed also TortoiseGit. I want to create a new clone by a right click in a directory, but the new Clone is not available after the right click. Does it need additional configuration? If no, what should I do from TortoiseGit to checkout an existing project?
I'd usually recommend learning git from command line. But if you are already familiar with TortoiseSVN then TortoiseGIT is a good tool for you.
Also, I think you should learn git very well. I can recommend the book Pro Git.
To "check out" a git repository is called clone in the git world (you will get a whole copy of the server repository). This can be done either from command line or TortoiseGIT.
git bash:
$ cd /path/to/my/projects
$ git clone url-to-server-repo
Update:
Since you get the "normal" TortoiseGit menu (without clone option), it seems you already have a local git repository. You probably created an empty git repository by mistake. Look for a hidden directory .git in the project directory or any parent directory.
right click on the folder (not right click on nothing in the folder, the icon of the folder you want to clone INTO from the parent directory) and select clone from the menu.
FYI:
clone = create a copy of a repository.
checkout = change the current state of an existing repo to a saved state.
so if you have a repo w/ 3 commits (A,B,C) when you clone the repo you will be at the most current state (C). if you want to see the previous state of the repo you would git checkout B. if you want to see the repo's initial state you would git checkout A
hope that helps.

Am I using EGit and Eclipse correctly when working with repositories?

I'm trying to set up EGit with Eclipse and I've used neither of them before. I understand the basics around Git and Eclipse is more or less just another IDE. The problem I'm having is setting up a reasonable work environment.
I have file-server at home which I want to use as a Bare repository which I push and pull changes to. To test it out I've done the setup locally.
I have a bare repository created through the Git Repository perspective.
I've cloned that repository into a local non-bare repository.
I've created a project in a subdir of the non-bare repository (is this the way to go? Is it possible to do have the project directly in the workspace with the .git folder within it? So far I've had a lot of trouble with it when trying to create an Eclipse project out of it. What is the proper way to do it?)
I've made some changes to this cloned repository and added the indexes, committed the changes and attempted to push the changes to upstream.
The thing is that no changes are made to upstream. Would someone like to explain the procedure in doing the push so that I'm not misunderstanding something? Or am I completely wrong on utilizing a bare repository instead of just working non-bare?
As mentioned in this tutorial, you create your Git repo right where your project is (ie your .classpath and .project files are).
Pushing to a bare repo is a good idea (see the links mentioned in "Git - pull & push - production server")
You need though to specify what you want to push:
Click at least on "Add all branch spec".