I am trying to establish a git subtree in my project and for some reason I keep getting a message saying You must provide the --prefix option. I am making a Flutter project and the project repo (as well as sub repo) are both on gitlab.
Below is the command that I am running in the console while in my root project directory.
git subtree add —-prefix=subtrees/mysubtree https://git.company.com/subdirectory/subtree_repo.git master — squash
I have experimented a little with the command. For instance I tried —-prefix subtrees/mysubtree (sans =), as well as git config alias.sba 'subtree add --prefix subtrees/mysubtree / https://git.company.com/subdirectory/subtree_repo.git master —-squash'.
The last command doesn't throw any errors and it actually triggers pub get but no files change and no directories are added (at least not to the root which is where I am running the command).
I am not really sure what I am doing wrong and the messages (when there are messages) aren't very informative. I have checked my syntax and referenced it with Gitlab as well as with this post.
Related
I tried to switch from a HTTPS to SSH repo using git. Below are the first commands I used.
Then, when I tried to add a branch to the staging area, I got the following messages:
I am not able to push anything or add any commits to git from my command line either. I get an error saying "could not read remote repository". Could someone please help me? What should I do now? I am new to git and I don't want to dig myself in a deeper hole!
Check for a .git/ subfolder in:
your current working directory (where you switch to SSH)
your parent folders
If you see one in any parent folder, that would make your current working directory a nested Git repository.
Ideally, there should not be any parent Git repository above your own: see if you can remove those parent .git folders (or move them elsewhere).
I try to init a new Git local repository using either Git Bash or Egit in Eclipse. It always creates it in some default directory rather than current working directory (or specified path in case of Egit). EGit after trying to clone a repo returns an error that specified folder "does not look like git repo" - because it failed to init it correctly. Whatever I do, git init always produces files in the same place. Any idea?
I managed to find the reason. Git (and Egit which is also respecting environment vars) is using the path specified in GIT_DIR environment variable and completely ignoring current working directory. I once specified GIT_DIR in windows env vars, but then deleted it and it was not on the list anymore. Somehow, when I echoed it in Git Bash it was still there. Adding it again in windows vars and deleting again did the job.
Here I should note two bugs I discovered:
Windows is not always deleting environments vars and the may stay there with the old values (probably difficult to reproduce as it does not occur always).
EGit is respecting the GIT_DIR variable but still asking for the repo directory. This produces an error because the .git folder is in completely different location that Egit is looking for.
After my first attempt at committing a couple of large folders (angular and django), git responded with:
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Previous posts recommend:
removing the index.lock in the .git folder.
I've done this, but the second that i resubmit "git add . " as part of my git push origin master routine, the index.lock file reappears in .git
Is there another solution? And what has happened to warrant this?
I've tried all the suggestions in the commented link
I'm working with this:
git version 2.13.5 (Apple Git-94)
In my case, index.lock wouldn't delete. Instead, I found that one of my django folders lacked a .gitignore, so I created one and included the following files:
include
lib
include
bin
.vscode
You might want to include more or less, depending.. Apparently, I was attempting to push a file that disagreed with git.
So I'm trying to learn how to use GitHub... now my computer's out of whack.
fooled around with a folder - c:/documents/class/lab1part1, typed git init for that folder. Couldn't upload, made some mistakes.
Changed folder to c:/documents/class/lab2part3 and ran git init. made mistakes.
Went back to c:/documents/class/, was able to successfully upload (git init, git add, etc).
Went to github.com and all folders and files were there... except for folders (with files in it) lab1part1 and lab2part3.
So, I deleted that repository and started all over again...
Googled, one site said to use the command "rm -rf $HOME/.git" to undo the git init on my folder.
I typed that in git bash... and things went to hell.
This was done on a macbook pro that dual boots OSX and Windows 10 (clearly this occurred on the windows partition).
Right now - I'm unable to access the start menu, my programs that were in the task bar are gone, I'm unable to access connect to a network or any of my files.
What happened, and how to I fix this - i cannot afford to lose my labs!!!!
Putting aside the rm -rf step:
your lab1part1 and lab2part3 were not on GitHub because you create a git repo in their parent folder c:/documents/class/: when you pushed that repo, the two subfolders were recorded as nested git repo gitlinks (a special entry in the index)
as long as those folders are on your local machine, you will be able to add, commit and push once again (but you will need to push to two separate GitHub repos)
So save your folders elsewhere (backup), re-install Windows, and try agian.
I've got Composer installed and I've used it to download HTMLPurifier locally. Now I'd like to push that download to my OpenShift Git repo. So, in a Git Bash window, I run the following...
git add -A :/
git commit -a -m "Uploading HTML Purifier"
git push origin master
At this point Git reports that the push was successful but when I ls the directory through SSH, it shows that the HTMLPurifier directory is empty. Why is that? How do I get Git to push those files?
Additional Info: I noticed that the HTMLPurifier directory is indeed a Git repo itself and contains a .gitignore file in its root directory. I tried deleting it and re-running the above commands but to no avail...
You should try to avoid pushing downloaded dependencies into a repository. It is recommended to add the vendor directory into the .gitignore file at top level. But what you must do instead is commit and push both composer.json and composer.lock.
Here's why: The vendor directory is managed by Composer. Running Composer will probably do minor things during an update, but may also be doing heavy stuff if the Composer team decides to optimize things.
Also, if you require a branch of a package, and Composer knows the repository of that package, it will default to cloning a Git repo or do a SVN checkout instead of trying to grab a ZIP package of that branch (often there is no way to get such a package for branches, and even tagged versions in a plain Git repository do not have such download ability. Composer knows that Github offers such downloads, and detects Github by looking at the repo URL.)
So you can assume that Composer will put a lot of repository meta data into the vendor file, and if you blindly commit these, things will get ugly. First of all, you are committing way too many files, increasing your repository by an unnecessary amount, which will slow down things. Then, if cloning Git repositories, these will be treated as submodules, and that has another bunch of nastiness I am told. If you are just learning Git, it probably isn't a good idea to start with these. And if you are sufficiently known to the tools (Git and Composer), you probably won't need them either.
There really is only one reason why you'd try to commit a modified version of the vendor directory: If your release process is completely depending on all files being present in your one repository, without any way to run a composer install during the release to make these files appear on the target server.
In such cases, you'd install or update the packages with Composer, and then go through all created directories and delete any .git and .svn (and probably also .hg for Mercurial) folders you encounter. Only then you'd be able to commit the files into your own repository.
But note that this step might be a tedious step to do manually - you probably want to create an update script that does all that work for you. You also might run into issues when updating dependencies because Composer expects files to simply go away when deleted, and not be in the way when being written. I cannot tell you exactly what you'd be experiencing because it depends on how you'd do stuff, but I expect you stumbling upon random puzzling issues.
Bottom line: Avoid committing the dependencies into your own repository if possible.
Try using the -force option, you will also most likely need to delete the .git directory inside the HTMLPurifier directory too.