Tim S.
Tim S.

Reputation: 13843

Git pushes not visible in repository

After several massive failures at work I've decided we should have some sort of version control at work. I picked git.

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

Answers (2)

d12frosted
d12frosted

Reputation: 1280

I am not sure, but maybe git commit before pushes will help?

Upvotes: 0

asm
asm

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.

  • If the branch currently checked out is the branch you're trying to update the push will fail.
  • Otherwise, the branch your pushing to will be updated, but the working copy will not change because a different branch was updated.

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

  • On Server
    • git init --bare --shared=true
  • On your machine
    • git clone /path/to/remote
    • git checkout -t -b mybranch
    • [do work, commit on mybranch]
    • Either
    • git checkout master && git merge mybranch && git push origin master Updates master on the remote
    • git push origin mybranch Create the branch mybranch on the remote without updating master.

Upvotes: 1

Related Questions