Syncing .git directory
Hey,
I'm developing with pycharm locally on my windows 10 machine. and have a guest VM machine with ubuntu which contain my remote deployment server. I'm using SFTP for syncing between the two environments. my problem is that it seems like pycharm uses a local windows based git to locally manage the git operations. so its seems there are two seperate .git directories, a local one and a remote one.
My question is, what if i do some stuff on the remote machine like "git checkout otherbranch" or any other commit operation which is done remotely and manually. i would like the remote and the local .git to be always synced.
now i know its not syncing because of this configuration:

And I've been wondering if removing the ".git" directory is a bad/dangerous practice? if so, what would be the best way to achieve my goal?
Any help is much appreciated!
请先登录再写评论。
Why don't you use git push/pull to sync project?
@Rotem - did you find a solution? I have the same quandry. The issue with using git push/pull is that the Git remote is not the remote development server that has the source code checked out.
E.G.
Git remote with source repo -----> git clone on both the remote server + local server
(on local server) -----> do development work (and sync with remote server using IntelliJ)
(on remote server) -----> git commit -m "my commit"; git push
Now the situation exists on the local server when I do a "git status" and it shows me the diff (whereas on the remote development server it shows no changes, because they were just checked in).
Hi David,
Could you please report an issue to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY with all the details?
Done.
https://youtrack.jetbrains.com/issue/IDEA-201322
I believe this is more of a "how-to" question rather than an issue. Any help appreciated, thanks!
> The issue with using git push/pull is that the Git remote is not the remote development server that has the source code checked out
Why do you push to some other remote that directly to deployment server then? This will not sync your working trees though, but probably Deployment would do.
However, it looks like you are trying to make git a centralized VCS, while it is not designed to work this way.
I have the same problem and did try remove .git from the exclude items text box. This mostly works except for two issues:
1) I need to have different autocrlf settings as the local is windows and the remote is linux. This can be solved by going to Deployment > Excluded Paths and entering <repo path>/.git/config. Now everything except git config is synced.
2) As changes on the remote are not automatically downloaded, I have to manually download the .git folder if I do something like rename or delete a file on the remote. After downloading, the changes don't always seem to have an effect though. For example, I moved a folder into a subfolder and Pycharm is showing everything in the subfolder in red (i.e. unstaged), even though when I git status on the remote, everything is up to date.
I believe syncing git folder via Deployment is not a right thing to do, as it syncs everything including the index state. There are special git commands to achieve what you need - git push and git pull, which transfer commits without other unnecessary info.
I think it might be solved with some hook on the server, e.g. post-receive one. It could e.g. push changes to the target server, or ssh to the server and call git pull.
> For example, I moved a folder into a subfolder and Pycharm is showing everything in the subfolder in red (i.e. unstaged), even though when I git status on the remote, everything is up to date.
That's exactly what I mean about unwanted repo state syncing.
It may be better to sync git via push to remote, but I prefer tools that inform me rather than automatically exclude without a way to remove exclusion of .git.