I've got a repository. When downloading this repo, instead of cloning it, it seems that I accidentally simply downloaded the source instead. Now I've come to commit my changes and noticed that the folder I'm working in is, in fact, not a repository at all but just some random folder.
I've found various ways of initializing a new repo from existing contents. But how can I initialize an existing repo from my existing contents? I added the remote repo as a remote in the GitHub for Windows client, but it doesn't seem to have had the desired effect.
Just to be clear, the intended outcome is as if I had cloned it properly in the first place- history, diffs of the changes I've made from the latest in the repo, the works.
I've tried some solutions involving git clone, like "Clone into a new folder and then just copy and paste the .git folder". However, this seems to have the effect that Git thinks that I deleted and re-added every line of every file in the repository instead of the changes I really made.
From what we talked about in the comments, you should copy over the actual data to the properly cloned repository as opposed to the .git folder. This way, Git has a chance to pick up the changes without introducing any aberrant or unusual state issues.
Related
I want to have two separate versions of a file: One on github and one on my local machine.
More specifically, how do I ignore a commit coming from the remote server. In this particular case, I modified the file on github, committed it, but I want it to not change on my local machine.
I put the readme file on .gitignore.
Changed the file on github.
Made a commit
Fetched the commit on my local machine using VS2017.
How do I "ignore" the commit. And keep the two versions separate.
You can at least try:
git update-index --skip-worktree -- README.md
As I mentioned here, that would resist a git pull.
And you would keep a local version of README.md, different from the tracked one from GitHub.
I don't presume to know if it is a good idea or not, in your particular situation.
Note: I am relatively new to Git / GitHub. I understand my way around, but I am confused with this corner case
Background
I created an IntelliJ color scheme git repo and pushed it to github online. The directory structure was ad hoc and made up of only output. This was actually fine and worked well.
I noticed that people would not get updates from me this way, and decided to create a JetBrain Repo plugin. This also works well; however, my github location and plugin location on my PC are different.
Issue
I looked over Change Git repository directory location. but was not sure if this fit my usecase.
Since my github is just output files and my plugin files are all input files, can I simply just copy over my .git files (along with README files and such) , and expect it to work correctly?
The linked SO question seems to relate to JUST moving the same directory structure and files over to another location. I am dealing with different directory structure, different files, and directory location; however, it IS the same project.
Update
Before, my workflow was:
Modify Color Scheme in IDE
Export settings from IntelliJ
Place in \Documents\GitHub\ChroMATERIAL
Windows GitHub Client: \Documents\GitHub\ChroMATERIAL merge
GitHub
Now it is
Modify Color Scheme in IDE
Run project and autogenerate output in \IdeaProjects\ChroMATERIAL
Place output in \Documents\GitHub\ChroMATERIAL
Windows GitHub Client: \Documents\GitHub\ChroMATERIAL merge
GitHub
What I want
Modify Color Scheme in IDE
Run project in \IdeaProjects\ChroMATERIAL
Windows GitHub Client: \IdeaProjects\ChroMATERIAL merge
GitHub
I'm assuming that the generated output matches the structure you need for your Github repository. If so you could easily move your .git folder from
\Documents\Github\ChroMATERIAL
to
\IdeaProjects\ChroMATERIAL
What you should check:
Will the generated output directory be cleared if you clean the project into Intellij? If so you should stick to your current workflow since you could easily delete your local copy.
The other thing which could be a problem is the Github Desktop Client since I don't know how it behaves nor how or if it must be configured in a special way to reflect your changes. (if you just call it from the inside of the repository it should not be a problem at all)
For your explanation:
Git uses relative paths. So it is irrelevant where the repository lives inside your system. The important part is the structure inside the repository since this will be cloned to the remote repository.
I recommend that you copy your .git folder rather than move it. If something goes wrong you can easily revert.
This is about outdated repo details inside XCode. The case is:
I'm reusing a supporting library from an old project in a new one.
I used "Add files to X project..." functionality to copy them to the new place.
"Automagically" the files were copied with a reference to an old SVN repo, that don't exit anymore.
So... Now I have a project with 2 repos visible, incl. one inactive. I can't commit changes to copied files, as the old repo is still linked.
Two question here:
Is there a way to edit old repo data?
Is there a way to move the copied files to the new repo, where the rest of the project is?
Ultimately I need to commit both parts ;)
Thank you.
OK. So resolving this issues required several steps to be performed. Not sure if all were required, but the eventually I got it right.
Commit all changes you can (in my case all but the folder that was linked with the old repo). Archive your projects.
Go to the root folder of your project and use svn switch --relocate command to merge repos. Details: how to change svn settings
Remove the project from XCode (via Organizer) delete the entire project folder
Remove repos in the Organizer
Fetch whatever was committed in the SVN again. Do that and create a new project. If you see any missing files highlighted in red, like my folder that couldn't be committed, delete it.
Manually add the missing files / folder that to the project, from a local copy.
Now you can commit to the repo!
Tiresome, like most things in XCode... ;)
I am using Git Extensions with Visual Studio 2010. My repository is on Bitbucket and I am using SSH and PuTTY to push/pull.
When I open my project and click on browse repository, the first thing I see is a window with a message that starts like this (
Along with two buttons for "Edit .gitignore" and "Commit"):
There are no commits made to this repository yet.
If this is a normal repository, these steps are recommended:
-Make sure you have a proper .gitignore file in your repository
-Commit files using commit
If this is a central repository(bare repository without a working
dir):
-Push changes from another repository
My working directory is set (in a drop down) to a local folder on my computer and the current branch is "master" (also in a drop down).
I can push, pull and commit changes and they will show up in bitbucket but the graph does not show up.
There is another drop down on the right side of the Git Extensions window that has "Branches:" as the label.
If I select "master" from the "Branches:" drop down then I see the graph but everything is gray.
I tried deleting my local repository and re-cloning it from bitbucket and nothing changed.
The graph looks the same as if I were browsing a remote repository... all of the branches and nodes are gray.
Also, I cloned the remote repository as a personal repository... not a central one... and when I first created the remote repository I did it as a central repository.
This does not seem to be a common issue... either that or I did not know what to search for on google.
Thanks in advance.
Edit:
The video at this link http://www.youtube.com/watch?v=cFbCusX9bKs created the repository differently than I originally did..... when I tried it that way it worked..... The difference was that you clone a fresh and empty Bitbucket repo to an empty directory as a personal repo then drop all of your project files into that folder and commmit then push to Bitbucket.......
It could be that my problem was that I created a central repo from an existing project and then pushed it to Bitbucket..... I hope this is useful for someone else.
The video at this link http://www.youtube.com/watch?v=cFbCusX9bKs created the repository differently than I originally did..... when I tried it that way it worked..... The difference was that you clone a fresh and empty Bitbucket repo to an empty directory as a personal repo then drop all of your project files into that folder and commmit then push to Bitbucket.......
What is the most simple way to backup my project? Can I just copy XCode project (with hidden .git) directory to USB stick and copy it back when needed?
It will work fine, but it is rather inefficient. I've done it with timecapsule and this just works.
You can also create a "bare" repository on the stick and regular push your work to it.
This is a lot smaller than the original, but you will not have all your branches (unless you all push them of course).
If you have a second computer then you can push/fetch the project back and forth, and you always have 2 copies. If you fetch from the remote PC you get all the branches.
Sites like github and gitorious allow you to push your repository to the cloud and also serve very effectively as a backup.
This is what is great about distributed version control : so much flexibility.
If your project is tracked with git. You can backup the git repo with git-copy.
git copy /path/to/project /Volumes/usb/project.backup
Then you can restore your project with git clone
git clone /Volumes/usb/project.backup project