I have a PC where I have both a Linux and a windows installation. I use a cloud service so I have access to my important files in both places, and they are synced.
Say I created a git repository, and pushed it to GitHub on windows. Now I suddenly feel the need to switch to my Linux installation to do some stuff. My cloud service does not sync the .git folder, since it's hidden in default by windows. (Would it lead to problems between os'es if i would sync it?). Therefore, Even though I have the same project (with exactly the same files) as on windows, Linux does not automatically recognize the VCS settings of the current project.
I found a somewhat dirty workaround, on Linux I
Initialize an empty rep: git init
Add a remote branch:git remote add Project_name https://github.com/Psychotechnopath/Project_name.git
Fetch the contents of the remote branch git fetch --all
Reset the head onto the remote master branch git reset --hard Project_name/master
Is this the best way to do it (e.g. respecting the git workflow), or are there more elegant ways?
I have mostly-successfully done this on the same filesystem; in my case I mounted the ntfs filesystem from Linux. Two things you have to be careful of:
don't make filenames that are the same on a case-insensitive file system but different on a case-sensitive one
pay special attention to your line endings, you may need to do some work in .gitattributes here
push often in case you find a git bug
If you don't mind having the world's slowest Linux system, you can also just run Linux under Windows via Window Services for Linux, WSL. (Not WSL 2, that's containers). In that case, you can access your windows repo from linux via the /mnt/c/ filesystem.
Related
I have been working on some code on my mac and want to start working on it on my linux desktop. The project is managed under git. Before the copy, I made sure everything was committed. I then copied the folder containing everything from my mac onto a usb drive, then copied the folder from the usb drive to the linux box. After the copy, everything looks like it is where it should be, but if I do a git status all the files show up as modified. I'm guessing this is because the timestamps on the files have changed. Is their a way to retain the old timestamps so the files dont appear modified? Or to tell git to not worry about changes since the last commit? I'd prefer not to do a git commit -a immediately after the transfer as I dont really want the move of boxes in my git history.
The easiest thing to do is to use clone (rather than copying worktrees around) to share repos.
If you cannot directly clone / fetch / push / pull between the two machines, then you could create a "bundle file" and copy that, instead of copying the actual repo. (See the git bundle` docs or search for existing questions/answers about how to share a repo in this way.)
When crossing operating systems, there are still potential issues. e.g. You'd want to think about how you want to handle line endings if crossing between OS's that have different default line ending rules - but mac and linux shouldn't have that issue anyway.
Assuming there's a Git repository hosted on a Linux machine and there are developers using both Windows and Linux, is there a way to prevent Linux developers from committing files with same names but different cases?
I think I've to write a server-side hook for this, but I don't know how to validate the names of incoming files inside the hook script.
Any help/references related to this would be appreciated.
If you want keep some files locally then git stash is your friend. stash usage
I'm developing an (Qt) application which should run under Windows and Linux. So, I want to be able to develop under Windows and Linux, too.
Therefore I have stored my project (as git repo) on a NTFS partition which I mount under Linux (Ubuntu 13.10). To avoid the rights problem of the compiled executable I set the shadow build directory to my home folder under Linux.
This approach work quit good so far. But there are some effects that make me worry: If I stage some changed files (with smartgit), smartgit doesn't reflect that I have stage them. They are still displayed as unstaged
Similar thing when commiting: After the commit, the commited changes are still display as if they where not commit. But in the log I can see they are commited. Closing an reopen the repo "solves" this issues or is a workaround at least.
But I have concerns that I break my repo using it on a NTFS partition under Linux. Or is there no risk that my repo is getting corrupted one day using it that way?
This answer has been given by Fco P. on the askubuntu question mirror. This happens because Windows and Linux deal with file permissions differently. Use
git config core.filemode false
to disable git tracking file permissions and solve this issue.
my current setup is as follows:
We have a Linux samba share that contains all the repository folders (with the hooks folder inside, amongst the others)
All the developers have the share mapped as a network drive, and import to a local directory (normally C:\Server\RepositoryName) where they work on their files.
All the machines accessing the drive (unfortunately) run windows.
What I'm aiming to do is to have a hook on the Linux server that detects when a commit has been made, by which project, the revision number, the name of the developer who committed, etc. I looked into the hooks files, but they seem to be ran by the client. Is there a way to monitor svn changes and collect the relevant information from the Linux server?
All the hooks are executed by svnserve. Check your hook scripts, svnserve configuration and http://subversion.apache.org/faq.html#hook-debugging
This is maybe unusual so let me set the scene:
We have an SVN repo containing our project history - an embedded system based on Linux. The SVN repo contains Linux kernel, U-Boot, busybox etc. sources and all our in-house apps, filesystem and such.
The Linux kernel we have is old and crusty and I am working on porting to the mainline, which is under active development for our platform(s). I am doing the kernel-side work under git and trading patches with "The Community".
I could get things working and take a snapshot of the kernel sources and dump it into SVN, but I'd like to keep the ability to get updates, have local branches and manage patches with git. I could keep two copies of the kernel, one managed by each SCM, but that would be a bit messy. There are also risks of developing and testing using kernel sources managed under git, and forgetting to put those changes into SVN resulting in broken SVN versions where the non-kernel sources are out of sync.
Migrating the entire project to git isn't an option. Managing just the kernel source with git and having a bunch of glue scripts and stored hashes in SVN is possible but it's nicer to have a unified history / diffing ability from SVN for the whole project.
What I'm considering is trying to manage the kernel sources under both SVN and git simultaneously, in the same directory.
As a kernel dev I'd mostly use git and do an SVN commit for internal use when things look good. For other internal users they would be able to get the entire, consistent sources with one SVN checkout, see a unified history, and they could make changes to the kernel sources under SVN. Later I or another git-using person can SVN update to those changes and commit them to git as appropriate.
Some funning around getting git to ignore .svn files and vice versa will have to be done. Also I'm not quite sure how one would take a plain SVN checkout and tell git to start managing the kernel subtree as well, but I'm sure git has some obscure swiss-army-knife options to do it.
So that's my idea du jour. It means most co-workers don't have to worry about git, and we can quietly ignore git and fork away later as needed.
The question here really is, has anyone done something like this, how did it work out, or what alternate solutions did you come up with?
I've done this regularly, and it works great.
The only major thing I needed to do was add the .git folder to the subversion ignore list, and the .svn/ folders to the .gitignore file.