I created a github repo for some scripts I use in order to keep from having to remote into the server every time I want to make a change.
This code needs to exist simultaneously on two different servers, and one of the servers doesn't need all of the files that the other one does.
Is it possible for me to sync a repo over two different servers each having their own gitignore files?
It's possible to have different exclude information on both servers [1]. However with that said, this won't stop a pushed file from being downloaded on the server that has that file excluded. There is no way to stop git from pulling all files when you pull.
You would need to have two repositories if you have different files, or use some sort of submodule approach for shared files (repoA and repoB go to serverA and serverB, and both include a shared submodule repoShared) - but this is now really pushing what is already a non-ideal use case for git.
[1]:
Git stores exclude information in $GIT_DIR/info/exclude (where $GIT_DIR is your .git folder within you repository), so you could hardcode relevant files in there.
Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:
git update-index --assume-unchanged [<file>...]
See the relevant documentation, or previous posts on similar matter.
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.
This is my scenario. I'm having two Git branches and we will name them as "Aaa" and "Bbb". Remotely there are two separate Git locations for those two as well. So I can commit and push remotely with unique changes to there branches.
What I curious is, when I need to merge those two branches, I don't want some specific files to be merged at all. As an example in my Xcode project, I don't want info.plist file to be merged when I'm trying to merge above mentioned two branches but need to merge AppDelegate.m
Is there any way that I can write a script or add some lines in .gitignore file to achieve that task.
If I explain it further more, it is like, when I add some files to .gitignore, local changes to that files is not affecting to remote git server files. I want to know such kind of behaviour is existing with merging two local branches.
There is a project that uses CVSNT/WinCVS for Version Control. This is the central repository. Locally checked out folders contain hidden sub-folder called "CVS".
I tried to install CVSNT server locally and use second instance of WinCVS to manage(version control) local temporary changes before committing to the central repository.
But that is not working because when checking out from the second(local) repository it still uses "CVS" sub-folder name for its working files.
Anybody knows if it is possible to configure CVSNT server and/or Client to use different name for this sub-folder? And if yes, how?
So far I'm using TortoiseSVN. It creates folders too, but they called ".svn" so there is no interference. It is integrated in Windows shell, which I don't like.
A sandbox is tied to a given repository (which is regitered in one of the files in the hidden CVS folders). You can't use the same sandbox to commit locally and remote (are you tring to mimic a DVCS? Use one of them if you need them). You can't change the folder name (but changing the CVS source files...), but beware WInCVS use them as well because they contains informations about the files status.
You have two options:
The CVS way: create your own development branch, commit to that, merge with the main branch when your code is ready. Of course the CVS server has to be reachable all the time.
The DIY way: create two sandbox, one from the local repository, one from the remote one, move files between them as you need. This is a more error prone way, IMHO.
Of course you can try to use two different VCS, but you will end up with a lot of headaches then. Better to use Git, Mercurial or the like that do what you need without any special configuration.
Switching to GitHub and can't seem to find information on how to do something I used to do with SVN:
First of al I'm a tester so I never commit changes, but I do need to keep a number of local copies of the project each with a small difference to trunk - staging, production, decreased timer values etc
I used to use CornerStone on Mac (just fwiw/don't have it any more), and a single update from SVN would update all my various local 'dependent projects' (all of them the same, apart from one or two lines, usually in a config file). I'd review the inevitable conflicts and almost always reject them, provided the only difference in the conflicting file was my customisation for test purposes, or if there was something new I'd merge it in and leave my staging environment URLs or whatever as they were.
Can I do this sort of thing efficiently with GitHub? (preferably using GitHub's/Xcode's or some other Mac GUI client?)
I did look at the documentation, but can't seem to find anything on this so any help much appreciated/maybe it's kind of unusual to be pulling changes to lots of almost-identical local projects and always be rejecting certain conflicts.. :)
Of course, the ideal solution is to not have configuration data tracked in the repository, or at least make it possible to override via some untracked file.
However, there's no problem with what you want to do in git. You just locally make multiple clones of your GitHub repository. In each, you can make your changes specific to that local copy, and then commit them. Then, when you want to update from the latest version of GitHub, make sure that you pull with:
git pull --rebase
... which will fetch the latest version from the server, and then try to reapply your commits with local changes on top of them. Unless the same parts of the files that you've committed changes to have also been modified in the new commits on GitHub, you shouldn't even have conflicts to resolve.
If you always pull like this, then the commit graph (history) of your project will always be the same as the remote, but with any of your local changes as the most recent commits on top of the remote history.
(I would hope that the GUI clients that you are using have an option to rebase on pulling new changes. Otherwise you can set this to happen automatically with the config option branch.<name>.rebase, where <name> is the name of your local branch.)
I have a GitHub repository with two branches master and gh-pages. I am experiencing problems when switching between branches locally. Files and folders are not being copied correctly.
Is it possible to have each branch in a separate directory locally?
i.e.
/Users/macuser/github/my-master/
/Users/macuser/github/my-gh-pages/
instead of
/Users/macuser/github/my/
Yes, there's no problem. Just git clone twice, then switch to the branch(es) you want. push and pull as needed.