Git Workflow Suggestions

Hello


I am the single developer of a new project and am new to Xcode. I have experiance of using IntelliJ IDEA and Visual Studio but not Xcode. I want to be able to work on my project from several locations and maintain a remote repository on my fileserver in the design studio, which is regularly backed up and acessed via VPN. I can't use any externally hosted repositories, such as GitHub for various in-house reasons.


Can anyone suggest a sensible workflow and comment as to whether I should use the Source Control options in Xcode or use the GitHub desktop app or even Terminal?


Generally I would want to create a new Branch to develop a feature, commit along the way until finished on the new Branch, merge into the parent Branch and delete the feature Branch.


What troubles me is how I would work at one location (perhaps at home), 'push' the changes to the remote repository, move to another location (perhaps the studio) and 'pull' the updated repository to a MacPro there and continue developing. Any advise would be very welcome.


Regards


Chris

Xcode is like Visual Studio in that, when using git-based SCM, it expects you to have a local repository on your PC, linked to a remote repository on a server. It's not clear from your description if this is what you've been doing, or if you've been accessing the server repository directly via VPN from all of your PCs, and skipping the use of local repositories.


I'd guess NOT the latter, but it's hard to tell. If the former, then it works the same in Xcode as in Visual Studio. You initially clone your remote repository locally, then make the remote link in the IDE settings. (The details vary in what particular order you do things.) Then you can pull and push changes to the remote repository. Xcode can also create and merge branches.


It's also perfectly feasible to do your SCM outside Xcode, using any of several 3rd-party apps, or using the 'git' command in a terminal window.


Since this is similar to what Visual Studio does, perhaps you can clarify what parts of your current workflow you're worried might be missing from Xcode?

Thanks for your reply


As you expected I will create a local repository on each Mac I work on and configure Xcode to work from the local repository and pull/push to the fileserver over the VPN connection. As I am creating a secure VPN connection to the studio network, effectivly placing my Mac on the studio network, when configuring the remote repository I used the file:///Volumes/Projects... type path and not SSH or HTTPS. Is this OK?


I created some simple test projects yesterday to try things out and found one curious aspect of Xcode which I am sure is only my lack of understanding. I will try and simply explain the scenario:


  1. Create a new Xcode project on Mac 01 and push it to a bare repository.
  2. Perform some work on Mac 01, commit the work to the local repository and push to the remote.
  3. Move to Mac 02, create a new project and pull the work from the remote.
  4. Perform some work on Mac 02, commit the work to the local repository and push to the remote.
  5. Create a new branch (named dev) on Mac 02, edit a file and commit to the local repository.
  6. Push the project to the remote so the remote now has 2 branches, let's call them master and dev.
  7. Return to Mac 01 and in Xcode > Source Control > Pull it asks me to select a Branch?


Can you explain what happens if you pull only one branch? I've not come across this before and expected to be able to pull everything down effectivly synchronising my Mac with the remote repository state.


Thanks

>> it asks me to select a Branch?


If you mean that Xcode displayed a sheet showing a popup of branches from which you can choose, then, yes, it always does that, even if there's only one branch. It's more of a confirmation than anything else.


If it's a question of why Xcode pulls only one branch rather than all of them, then I'd guess it's a philosophical choice. There's no presumption that client 01 and client 02 are both "you", so ( guess) there's no reason to presume that client 01 wants any other branches than the one asked for.


In addition, Xcode generally refuses to pull a branch for which the client has uncommitted changes. Pulling changes for a different branch might be problematic.


But that's just speculation. In Xcode it's usual to pull/push one branch at a time.

That all makes sense, thanks.


I suppose I am used to pulling everything as oposed to pulling an individual branch but I can see the benefit of being more targeted in the pull action. Suppose I have 2 branches, master and dev, and I am working on a feature on the dev branch. I move to another location and pull down the dev branch to continue working on it. If I commit the changes and then want to merge them into the master branch should I always pull the master branch first to ensure I am merging into the current master?


There are several good sources of reference for the commands and operation of Git but it's hard to find a reliable source of good practice in how to practically use Git. Your advise is valued, thanks.

>> If I commit the changes and then want to merge them into the master branch should I always pull the master branch first to ensure I am merging into the current master?


It's a workflow issue, with different answers in different cases, isn't it?


If you make an experimental branch and work on that without touching the master branch, but meanwhile someone else is working (and committing) on the master branch, when you come to merge your branch it'll likely be easier to merge into your out-of-date master branch before pulling its changes.


However, if you're also making changes to your local master branch, then you're faced with a 3-way merge, and I guess you'd do it in the order that seems to promise least trouble.


I can't think of anything in Xcode that's biased in favor of one approach or the other.

Git Workflow Suggestions
 
 
Q