Because I often take my work home to do it, some codes written on my home computer are often too late to synchronize with the code on the company computer, leading to confusion in code management.
Now using git for source code management is much easier, and it is also very convenient to collaborate and develop with others.
Proceed as follows:
1. Configure the server:
mkdir repos.gitcd repos.git
git --bare init #Create an empty git repository, the
--bare
2. Git management of the existing workspace on PC-1 and upload to the server:
cd workspacegit init
git add *
git commit
-m'initial commit' git remote add origin ssh://[email protected]/home/huzhenwei/repos.git #192.168.1.2 is the VPN intranet IP of the server
git push origin master #Upload the local code to the server
3. Check out the version library from the server to PC-2, create a new file on PC-2 and upload it to the server:
git clone ssh://[email protected]/home/huzhenwei/repos.git workspacecd workspace
touch newfile #Create a new file for testing
git add newfile
git commit -m'add newfile'
git push origin master #local Upload the code to the server