If git-dir is not in work-tree, we can use the command line
git --work-tree=/a/b --git-dir=/c/d/ status
to run git. How can we use magit in this situation?
Thanks.
Create a file /path/to/worktree/.git with contents gitdir: /path/to/gitdir and in /path/to/gitdir/config set core.worktree to /path/to/worktree. You can also use relative paths. Git commands which create separate worktrees do that (e.g. git submodule).
git worktree does something a bit different because it has to support multiple worktrees. But depending on your use-case, you might be able to just use that command instead doing it manually.
Related
I've recently moved to Github (VS2017's built-in support) from Perforce for some individual projects. There is a feature in Perforce called "make writable" that allowed you to write to a file locally and then only submit it to the server by explicitly checking it out then submitting it.
This was used extensively for any binary files (.exe, etc) that only needed to be pushed very rarely but still needed to be written to.
Unfortunately from my limited experience with Github, it seems that all files are set to writable and are always marked as "changed", even exes. Is there a setting I can make or setup that allows Github to only mark a file as changed explicitly so I can't accidentally push an incomplete, broken, or debug .exe?
Updated answer: So, I forgot, if the file's tracked by Git at any point, then it gets a bit ugly. There are ways around this, but it isn't a single command to do this.
IF you want to do the .gitignore route, you can. But there's an added step (see below for first step). You have to, after each commit you do of the .exe file, run git rm --cached <filename>. This will remove the metadata around the file telling Git to track it. Once you do that, it won't show up anymore in the Changes list in the Visual Studio plugin (if you're on commandline it won't show up in git status). Then to add a file, you do what I mentioned below, which is to do the git add -f <filename>.
If instead, another way to do this, would be to run git update-index --assume-unchanged <filename>. This tells Git to ignore changes to the file. When you want to commit it, first run git update-index --no-assume-unchange <filename> and do your normal git add git commit workflow, then once you've committed it, run again the git update-index --assume-unchanged <filename> bit. It's messy, and honestly, I'd write a custom tool in VS to do this rather than relying on the built-in SCM tool in Visual Studio.
Original answer: Best way to do this (IMO, others will have their own opinion) is to add the files to your .gitignore. Then if/when you really want to commit them, do a git add -f <file> and then commit as normal.
Edit: Note that this is something everyone will have to do to avoid accidentally committing. A way around that is to commit your .gitignore as well so everyone has the same behavior.
Is it possible to save github commits (info about commit, branch, author etc.) to file and create graph with branches as image?
I don't want to make repository public, but I need to share my progress without giving access to repo.
I'm not 100% sure this is what you're looking for, but using the git commands you can do that sort of thing. Clone the repo on your machine, cd to the repo, then you can do something like :
$ git log --graph --decorate --glob="*"
See screenshot below.
If you don't need to do this from a script, you can just copy-paste the terminal output. Otherwise, I'm sure there's a way to place it all into a file.
This graphical output is, IMO, quite useful. I personally use git hist as an alias of the verbose command above.
This is the best solution I found, git log output as HTML file:
https://github.com/bluef/gitgraph.js
Anyway, #Anthony D. provided pretty simple and clean solution.
Fossil has a shunning mechanism, which I believe may be used to keep certain files from version control.
I have a directory named R, which I wish to control except for a sub-directory inside of it, named library, which I wish to exclude. How can I "shun" the sub-directory?
My usual workflow is something like this:
fossil new ../fossils/R.fsl
fossil open ../fossils/R.fsl
fossil add .
fossil ci -m "a commit"
fossil close R.fsl
The help page is here, but I still couldn't figure it out:
http://www.fossil-scm.org/index.html/doc/trunk/www/shunning.wiki
If I read your question correctly, you're looking for a way to keep specific files out of version control.
In that case, you're probably looking for the ignore-glob setting.
That setting allows you to specify (chunks of) paths that should be left out of the repository.
For example, if you wanted to leave all files in the subdirectory skip, and you also wanted to keep all *.bak files everywhere out of your repo, you could achieve this with the following command:
fossil set ignore-glob "skip/,*.bak"
The fossil set ignore-glob takes a comma-separated list, so this means any file starting with skip/ will be ignored, and all files matching the *.bak glob will be ignored as well.
If you want to test your ignore-glob setting first (it can be a tad tricky to get right, in my experience), you can test it using the extras command. fossil extras will normally show all files present in the working folder (and its subfolders), but are not in the repository. You can override the ignore-glob setting using the --override command-line switch; thereby allowing you to test it. If it works OK, you can save that ignore-glob with the settings command, as described above.
Do NOT use shun for this!
As the documentation clearly says, shunning is not recommended. It should only be used with great care, and only if you understand exactly what it does, because you can seriously fuck up your repository if you use it the wrong way.
Your question makes it clear that you don't understand its use, so I strongly suggest forgetting about shun until you're more familiar with the working of Fossil.
Do not use shunning. Use this:
cd R
fossil settings ignore-glob "library/*"
fossil settings ignore-glob
fossil ls
fossil extra
Here is a good guide for start https://www.fossil-scm.org/xfer/doc/tip/www/quickstart.wiki
Here's the problem: I'm developing a few projects that need to somehow store credentials used for external services - for example, an e-mail address and password. I figured it falls into "configuration" and decided to move the variable data into a separate file the program reads from. I don't want this file to be pushed to upstream though, because in some of my smaller programs, written for personal needs, I test on a production environment and the data are usually quite sensitive.
On the other hand, I don't want a basic .gitignore solution or its equivalent - instead of not uploading the file at all, I'd prefer to send another file in its place, an example configuration file, while keeping the "real" file on its place on my computer. Is there any simple way of achieving it?
If you need more details to answer the question, I'd prefer an answer regarding Git VCS, Python scripts and Linux OS.
One possible solution:
Commit and push a "sample" config file. Then, make the modifications you want to the local config file. It will now be marked as modified in Git.
Use git update-index --assume-unchanged config to permanently ignore future local modifications to the config file (use --no-assume-unchanged to resume tracking modifications).
This way, you will have a sample config in the upstream repo, a customized config in your repo, and you will not accidentally commit the changed config because Git will not mark it as modified.
Another thing you can do is use .gitattributes filters. It lets you specify certain files to pipe through a unix command. You could write a ruby script to scrub out your passwords and replace them with dummy values, or just use sed or awk. You could go a lot crazier than that and use it for some really dangerous things also, heh. See this other answer for some details.
I am using Eclipse and Subversion for Java development, and I find myself wishing for a feature in version control systems (one that is not available in SVN, to the best of my knowledge).
I would like my project settings files to be half-ignored. To be more precise, I want them to be available in VCS, I want merge to occur when someone checks in changes, but. I want my own changes ignored unless I very explicitly tell the system to take them.
This would allow me to have my local paths (and other settings) in my local configuration w/o screwing up other people's configuration. But, when I have a substantial change, I can still check it in (very very carefully, may be temporarily removing my other local changes) and have it delivered to other people.
Now, the actual question: is there any VCS that supports this feature? Or may be I am missing something in SVN? How do other people solve this problem in Eclipse?
Yes, Git support that feature through filter driver (a clean script can run upon commit, allowing you to clean the content from any of your changes if you want).
But another way would be to never version that setting file, and only version:
a template file
a value file
a script able to replace variables in the template files with the values from the value file, in order to generate the actual (and "private", as in "not versioned") setting file.
That way, you can modifying it at your heart's content without ever committing your changes.
.gitignore for git, .hgignore for mercurial and file paths and patterns can be added that will not be committed. There similar in SVN but i never worked out how to use it myself but my sysop did set it up form me.
git supports this with
git update-index --assume-unchanged <file>
and the complementary
git update-index --no-assume-unchanged <file>
See http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files and http://kernel.org/pub/software/scm/git/docs/git-update-index.html#_options for more details.