Git:结帐覆盖文件

时间:2018-11-13 09:18:06

标签: git atlassian-sourcetree

我想结帐一个分支,我收到了此消息

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.9/angular.min.js"></script>
    <script type="text/javascript">
        var app = angular.module('MyApp', [])
        app.controller('MyController', function ($scope, $window) {
            $scope.Customers = [
                { Name: "John Hammond", Country: "United States" },
                { Name: "Mudassar Khan", Country: "India" },
                { Name: "Suzanne Mathews", Country: "France" },
                { Name: "Robert Schidner", Country: "Russia" }
               ];
            $scope.GetDetails = function () {
                var details = '';
                $('[id*=tblCustomers] tr:not(:has(th))').each(function (index, item) {
                    var name = $scope.Customers[index].Name;
                    var country = $scope.Customers[index].Country;
                    var selected = $(item).find('[id*=ddlYesNo] option:selected').val()
                    details += "Name: " + name + "\nCountry: " + country + "\nAction: " + selected + "\n\n";
                });
                $window.alert(details);
            };
        });
    </script>
</head>
<body>
    <div ng-app="MyApp" ng-controller="MyController">
        <table id="tblCustomers" cellpadding="0" cellspacing="0">
            <tr>
                <th>
                    Name
                </th>
                <th>
                    Country
                </th>
                <th>
                    Action
                </th>
            </tr>
            <tbody ng-repeat="m in Customers">
                <tr>
                    <td>
                        {{m.Name}}
                    </td>
                    <td>
                        {{m.Country}}
                    </td>
                    <td>
                        <select id="ddlYesNo">
                            <option value="">Select</option>
                            <option value="Yes">Yes</option>
                            <option value="No">No</option>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <input type="button" value="Get Details" ng-click="GetDetails()" />
    </div>
</body>
</html>

但是我希望这些文件被覆盖

1 个答案:

答案 0 :(得分:1)

git checkout

https://git-scm.com/docs/git-checkout#git-checkout---force

您可以传递-f(强制)标志来强制检出分支,这将清除您所做的尚未提交的所有更改。

git checkout -f branch

如果您不想丢失所有更改,可以使用以下方法专门检出文件:

git checkout -- src/main/webapp/data/GuerrillaLabels.json

git stash

https://git-scm.com/book/en/v1/Git-Tools-Stashing

您还可以隐藏所做的更改,并在以后重新应用

git stash

您可以使用以下方式查看藏匿处

git stash list

您可以使用pop来应用这些存储。不向pop传递任何内容将应用最后存放的物品。

git stash pop

注意:此方法可能导致与代码冲突