主要内容

拉动,推和获取文件git

拉和推

采用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 thePull,Push, 和Fetch纽扣。所有其他操作都使用本地存储库(例如Check for Modifications,Compare to Ancestor, 和犯罪). This diagram represents the Git workflow.

  1. 要获取最新更改,在“项目”选项卡上的“源控制”部分中,请单击Pull。拉可获取最新更改,并将它们合并到您当前的分支中。

    Note

    Before you can merge, you must register model files as binary to prevent Git from inserting conflict markers. See用源控制工具注册模型文件

  2. 要创建分支以在“项目”选项卡上的“源控制”部分上工作,请单击分支。Create branches in the Branches dialog box, as described in分支并将文件与git合并

  3. When you want to commit changes, select the Modified files view to view files, and on theProjecttab, click犯罪。The changes are committed to your current branch in your local repository. Check thegit对当前分支信息窗格。你see the messageAheadwhen you commit local changes that have moved ahead of the remote tracking branch.

  4. 要将您的本地提交发送到远程存储库,在“源控制”部分的“项目”选项卡上,请单击Push

  5. 如果您无法直接推动更改,则会出现一条消息,因为存储库已经继续前进。点击Fetchto fetch changes from the remote repository. Merge branches and resolve conflicts, and then you can push your changes. SeePull, Fetch, and Merge

Pull, Fetch, and Merge

采用Fetchto get changes and merge manually. UsePullinstead to fetch the latest changes and merge them into your current branch.

Note

Before you can merge branches, you must register model files as binary to prevent Git from inserting conflict markers. See用源控制工具注册模型文件

拉可获取最新更改,并将它们合并到您当前的分支中。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, clickFetchon the Project tab.

Fetch updates all of the origin branches in the local repository.

Note

当您单击时Fetch,您的沙盒文件没有更改。要查看他人的变化,您需要合并到本地分支机构的原点更改。

检查GIT窗格以获取有关您当前分支的信息,相对于存储库中的远程跟踪分支。当您看到消息时Behind, you need to merge in changes from the repository to your local branch.

例如,如果您在主分支上,并且想从远程存储库中的主要分支进行更改:

  1. 点击Fetch

    观察Git Pane中的信息,Behind /origin/main。你need to merge in the changes from the repository to your local branch, using分支

  2. 点击分支

  3. 在分支对话框中分支list, select原点/主

  4. 点击Merge。This merges the origin branch changes into the main branch in your sandbox.

  5. 关闭分支对话框。现在观察Git Pane中的信息现在说Coincident with /origin/main。你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. SeeResolve Conflicts

推开空文件夹

Using Git, you cannot add empty folders to source control, so you cannot selectPush然后克隆一个空文件夹。您可以在项目中创建一个空文件夹,但是如果推动更改然后同步新的沙箱,则空文件夹不会出现在新的沙盒中。你可以运行检查项目which creates the empty folder for you.

另外,要将空文件夹推向存储库以供其他用户同步,请创建一个gitignorefile in the folder and then push your changes.

采用git藏匿处

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 theProject标签,在源控制section, click藏匿处。In the Stashes dialog box:

  • To create a stash containing your currently modified files, clickNew Stash

  • To view modified files in a stash, select the stash underAvailable 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, clickPop

  • 要应用藏匿处并保留它,请单击Apply

  • 要删除藏匿处,请单击Drop

Related Examples

More About