Reputation: 13843
After several massive failures at work I've decided we should have some sort of version control at work. I picked git.
cd /path/to/hd/
cd mkdir test.git
cd test.git
to make sure it isn't a bare repositorygit init
touch README.txt
to create a text filegit clone /Volumes/Data/git/test/
git checkout -b mybranch
git push origin mybranch
git checkout master
git branch -d mybranch
Everything appears to work so far. So I look up the files on the server, but they remain unchanged. When I open test.git
with GitX, the commits are present. The changes are there. But the actual files haven't changed.
What am I doing wrong?
PS. I followed this guide: http://rogerdudler.github.io/git-guide/
Upvotes: 0
Views: 123
Reputation: 8898
What your seeing is the result of pushing to a repository with a working copy. When you push to a repo with a working copy there are two possible results.
What you now have on the server is probably something like this:
A <- master
|
B <- mybranch
Where master is checked out, and since you haven't changed master nothing went wrong when you pushed to the server.
For this reason when you create a repository that you're going to use as a remote you almost never want it to have a working copy (i.e. actual checked out files). You want to create a bare repository, and also probably want it to be shared, like this:
git init --bare --shared=true
The shared
option can also be a number of other settings, see git help init
for options.
I think the work flow you're looking for is something along the lines of
git init --bare --shared=true
git clone /path/to/remote
git checkout -t -b mybranch
git checkout master && git merge mybranch && git push origin master
Updates master on the remotegit push origin mybranch
Create the branch mybranch
on the remote without updating master.Upvotes: 1