简体   繁体   中英

how to work in two working directories in git?

I work in two working directories in different machines. To manage two directories I made bare repository in "my com". If I do not care each time two directories are different and bare repository would sync one of them. Then sometimes "git push" fails. At the moment I am the only one who uses two working directories.

  1. Case 1: there is no collision in the files. Then it might be that
    "git pull" then "git push" can work. Is this right?
  2. Case 2: if the same files are modified differently in both directories, how can I deal with this problem?
  3. is it better to use branch? then it looks difficult also to merge.

still git is not so easy to me.

To start off: I would suggest going through some tutorials on how git works and how to manage remotes. The official Git documentation is a good starting place.

To give an answer:

Keeping both repositories in sync should be very simple.

For example:

If you are working on your office pc and have made some changes:

  1. Commit those changes
  2. Do a git pull pointing to your "local" PC's remote

If you are working on your local pc and have made some changes:

  1. Commit those changes
  2. Do a git pull pointing to your "server" PC's remote

In any case there is no need to push stuff anywhere since you are the only one working on these files.

Regarding conflicts: If you have changed the same file on both sides, you should know which version you want to keep and use a standard merge conflict resolution procedure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM