Use this workflow to work with a Git™ project connected to a remote repository. With Git, there is a two-step workflow: commit local changes, and then push to the remote repository. In a project, the only access to the remote repository is through the Pull, Push, and Fetch buttons. All other actions use the local repository (such as Check for Modifications, Compare to Ancestor, and Commit). This diagram represents the Git workflow.
To get the latest changes, on the Project tab, in the Source Control section, click Pull. Pull fetches the latest changes and merges them into your current branch.
Before you can merge, you must register model files as binary to prevent Git from inserting conflict markers. See Register Model Files with Source Control Tools.
To create branches to work on, on the Project tab, in the Source Control section, click Branches. Create branches in the Branches dialog box, as described in Branch and Merge Files with Git.
When you want to commit changes, select the Modified files view to
view files, and on the Project tab, click
Commit. The changes are committed to your
current branch in your local repository. Check the
Git pane for information about the current
branch. You see the message
when you commit local changes that have moved ahead of the remote
To send your local commits to the remote repository, on the Project tab, in the Source Control section, click Push.
A message appears if you cannot push your changes directly because the repository has moved on. Click Fetch to fetch changes from the remote repository. Merge branches and resolve conflicts, and then you can push your changes. See Pull, Fetch, and Merge.
Use Fetch to get changes and merge manually. Use Pull instead to fetch the latest changes and merge them into your current branch.
Before you can merge branches, you must register model files as binary to prevent Git from inserting conflict markers. See Register Model Files with Source Control Tools.
Pull fetches the latest changes and merges them into your current branch. If you are not sure what is going to come in from the repository, use fetch instead to examine the changes, and then merge the changes manually.
Pull might fail if you have conflicts. With a complicated change you might want to create a branch from the origin, make some compatibility changes, then merge that branch into the main tracking branch.
To fetch changes from the remote repository, click Fetch on the Project tab.
Fetch updates all of the origin branches in the local repository.
When you click Fetch, your sandbox files are not changed. To see others’ changes, you need to merge in the origin changes to your local branches.
Check the Git pane for information about your current branch relative to the
remote tracking branch in the repository. When you see the message
Behind, you need to merge in changes from the
repository to your local branch.
For example, if you are on the master branch and want to get changes from the master branch in the remote repository:
Observe the message in the Git pane,
Behind /origin/master. You need to merge in the changes
from the repository to your local branch, using
In the Branches dialog box, in the Branches list, select origin/master.
Click Merge. This merges the origin branch changes into the master branch in your sandbox.
Close the Branches dialog box. Observe the message in the Git pane now
/origin/master. You can now view the changes fetched and
merged from the remote repository in your local sandbox files.
When you fetch and merge, you might need to resolve conflicting changes. If the branch merge causes a conflict that Git cannot resolve automatically, an error dialog box reports that automatic merge failed. Resolve the conflicts before proceeding. See Resolve Conflicts.
Using Git, you cannot add empty folders to source control, so you cannot select Push and then clone an empty folder. You can create an empty folder in a project, but if you push changes and then sync a new sandbox, then the empty folder does not appear in the new sandbox. You can instead run Check Project which creates the empty folder for you.
Alternatively, to push empty folders to the repository for other users to sync,
gitignore file in the folder and then push your
Store uncommitted changes for later use by creating a Git stash. Use stashes to:
Store modified files without committing them.
Move changes easily to a new branch.
Browse and examine the changes within a stash.
To create and manage stashes, on the Project tab, in the Source Control section, click Stashes. In the Stashes dialog box:
To create a stash containing your currently modified files, click New Stash.
To view modified files in a stash, select the stash under Available Stashes. Right-click modified files to view changes or save a copy.
To apply the stash to your current branch and then delete the stash, click Pop.
To apply the stash and keep it, click Apply.
To delete the stash, click Drop.