1

I have a question that I edit my code using PyCharm in Windows platform, and build and run my code in Linux machine, I want to know what is the correct way to do version control using git? My current approach is

  1. using git in Windows
  2. build and run code in Linux
  3. checkout different branches in Windows and upload code to Linux(and not upload binary files such as .o files and .so files)

I'm not quite comfortable with this approach so I want to know the better ways. Thank you!

Qiu QM
  • 11
  • 2
  • Your exact workflow is not clear. Are you cloning the workspace in Linux? That's what you should be doing. Then on Windows every time you are ready to share new code you would `git push` those changes to the server and on Linux you would `git pull` the new changes down. – kaylum Oct 18 '21 at 04:21
  • @kaylum Thank you for your reply. I didn’t clone workspace in Linux (and I even don’t know what workspace is, sorry for that). I will search for it soon. But I kinda think so many pushes and pulls are too complicated and inconvenient for me (Currently, I edit my code in Windows PyCharm and PyCharm automatically upload my code to Linux). – Qiu QM Oct 18 '21 at 07:00
  • I do not understand what problem do you have. You do not want to do push and pull: fine, but so what it is the problem with git? If there is a "better way" (there is no "correct solution"): you can setup git (or your git repository options) to use NL in git, and CR/LF when you checkout in Windows. (Probably it is already the default, but it should not matter). Note: use UTF-8 for code (default in Python) – Giacomo Catenazzi Oct 18 '21 at 08:48
  • @GiacomoCatenazzi Sorry for my unclear statement. My current approach is do all version control (e.g. checkout branches, make commits) in Windows, edit my code in Windows (and the code will be automatically uploaded to Linux), (build and) run my code in Linux. I think there are better ways to do it, so I ask the question here. There are already some answers (including yours) here and I try to understand them. – Qiu QM Oct 18 '21 at 09:27

1 Answers1

0

and upload code to Linux

If your Linux machine is accessible through SSH (and has Git installed), a better option would be to git push your code to your Linux machine, using a:

  • bare repository
  • a post-receive hook to checkout/restore your code where you want on said Linux server.

You can see an example here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes, my Linux machine is accessible through SSH and has git installed. I know little about bare repository and git hooks and I will try to learn it. Thank your for your reply! – Qiu QM Oct 18 '21 at 07:48