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.
Related
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.
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.
Sometimes I have problems with my Laravel project after running composer update. I believe this is caused by changes in the Laravel application skeleton (https://github.com/laravel/laravel). How do I update my local project to reflect those changes?
From the awesome forum post on the Laravel forums by Kindari (http://forums.laravel.io/viewtopic.php?id=5367):
If you originally cloned this repository and still share a git history
with it, you can usually merge in changes easily. Assuming your remote
is 'upstream' pointed at this repository, you can do the following:
git fetch upstream
git merge upstream/develop
Alternatively you could cherry pick in individual commits
from the develop branch, but I won't cover that here.
If you downloaded the zip distribution originally or
removed the upstream history, you can still resolve your problem
manually. Look at the commits on this branch and make any changes not
present in your application. Usually the breaking changes are simple
configuration changes.
Since most of the changes are likely to be simple configuration changes,
another option is to do a diff on the root folder and the /app folder. You'll mostly see your own configuration, but you'll also see any new configuration items that you should add.
I usually use git pull request. A git pull request does a git fetch followed by a git merge. It works for me nicely. In other words, A git pull is what you would do to bring your repository up to date with a remote repository.
my Hg repo now needs to include a Git submodule (Restkit) as per the advised method in the site wiki.
However, I am not updating the git contents and should only be potentially reading/pulling in changes from the host.
It appears that when I came to make my first push of my main Hg repo it baulked at the Git one asking for a password. I think this may be because its attempting to authenticate against the Git site as well.
My questions are can I arrange this so that the Git repo is read-only(pull) or even static and/or get round the log in issue. Obviously the two different repos have different credentials.
Thanks.
P.S. using Atlassian SourceTree 1.5.3 on OS X 10.8.2, Xcode 4.5.1
I've just re-read this;
2.6. Synchronizing in subrepositories
Subrepos don't automatically track the latest changeset of their sources. Instead, they are updated to the changeset that corresponds with the changeset checked out in the top-level changeset. This is so developers always get a consistent set of compatible code and libraries when they update.
Thus, updating subrepos is a manual process. Simply run 'hg pull' and 'hg up' in the target subrepo, test in the top-level repo, then commit in the top-level repo to record the new combination. The onsub extension can be used to automate that.
Assume this means its not pulling the sub? but I still have the above issue of the password request.
You moved in the right direction, but not finished all required steps.
You have to have subrepository, create it by hand... and don't mix real subrepository with a) independent b) nested repository
When you'll convert nested to subrepo push into master repo will not perform push to subrepo (except it requested)
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