0

I recently took over the development of a Python/ Django project, where Git is used as the version control for software maintenance and releases etc.

Having not used Git much at all before, I am still getting used to how to use it to manage version control effectively.

I recently pushed some changes to the server to fix a particular bug- this bug has now been fixed, and the feature is working correctly on the live version of the software.

However, when merging the branch on which I had been developing with the master branch, I needed to reset to an old version of the code as I managed to break my local master branch.

Now, having pushed my local master to the server, with the fix for this bug implemented, it seems that I have broken another page on the server- there were some issues with this page a month or so ago, which I fixed at the time, and the reset that I performed on my local master was to a version that was last modified a few days ago, so this bug should not have been in the version that I reset to, but somehow this seems to have broken this other page, even though it was working prior to pushing the most recent bug fix to the server.

I have several branches on my local machine, so tried checking out an old one, where I know that this page still works- and having browsed to it on my local server, I can see that it does.

I then ran a git diff master exportAddsOmits, where exportAddsOmits is the name of the old branch on which the broken page is still working. This command has produced the following output:

 (moon) user:moon user$ git diff master exportAddsOmits
diff --git a/buying/views.py b/buying/views.py
index 08d2fd6..b2f8fe6 100644
--- a/buying/views.py
+++ b/buying/views.py
@@ -651,10 +651,7 @@ def order(request, supplier_id):
            # project = Project.objects.get(id=request.GET.get('project'))
            order_form.initial['project_raw'] = request.GET.get('project')

 -       #project_choices = OrderItem.NON_PROJECT_CHOICES+[('', '-----')]+[(project.id, project.project_name) for project in Project.objects.filter(archived=False, detailed_status=Project.ds9).order_by('project_name')]
-       #(23/11/2016 @ 1110) Add 'Deposit Received' projects to drop down in 'Item Project':
       project_choices = OrderItem.NON_PROJECT_CHOICES+[('', '-----')]+[(project.id, project.project_name) for project in Project.objects.filter(archived=False, detailed_status=Project.ds9).order_by('project_name')]+[(project.id, project.project_name) for project in Project.objects.filter(archived=False, detailed_status=Project.ds8).order_by('project_name')]
-
 +       project_choices = OrderItem.NON_PROJECT_CHOICES+[('', '-----')]+[(project.id, project.project_name) for project in Project.objects.filter(archived=False, detailed_status=Project.ds9).order_by('project_name')]
    top_category_choices = [('', '')] + [(cat.id, cat.name) for cat in Category.objects.filter(parent__isnull=True).distinct().only('name')[:10]] + [('OP', 'Office Purchase')]


 diff --git a/costing/models.py b/costing/models.py
index 5b78684..d845da7 100644
--- a/costing/models.py
+++ b/costing/models.py
@@ -732,12 +732,8 @@ class Deposit(models.Model):
    def adjust_payment(self):
            p = Payment.objects.get_or_create(project=self.project, is_booking_deposit=True)[0]
            p.date_paid = self.date_received
-               print "p.date_paid has been set to self.date_received in Deposit.adjust_payment (costing/models.py)"
            p.amount_exc_vat = self.amount_exc_vat
-               #p.deposit = self.deposit
-               # ERF(21/11/2016 @ 1645) Try adding a line for date_received
-               #p.date_received = self.date_received
-               #print "p.date_received is being set to self.date_received in costing/models.py (line 739): %s " % p.date_received
+               p.deposit = self
            p.save()

         def __str__(self):
 diff --git a/costing/templates/costing/adds_omits.html b/costing/templates/costing/adds_omits.html
index 4d28188..a33fde5 100644
--- a/costing/templates/costing/adds_omits.html
+++ b/costing/templates/costing/adds_omits.html
@@ -24,12 +24,6 @@

What I'm not sure is how to interpret this... There are a number of lines beginning with either + or -, which I understand to be the diff command showing me lines that exist in the first branch, but not in the second, or lines that don't exist in the first branch, but do in the second... but I don't know which way round this is...

Are the lines beginning with - lines that exist in the first branch that I gave the diff (i.e. master), but not the second (i.e. exportAddsOmits) and lines beginning with + lines that don't exist in the first branch (master), but do in the second (exportAddsOmits), or is it the other way around?

Will I need to resolve these differences manually, or can I merge the old branch (exportAddsOmits) with my master branch? If I do merge, is this likely to undo the fix that I have just implemented?

1
  • Your diff output looks like a combined diff. Are you in the middle of a conflicted merge? (What is the output from git status?) Commented Jan 5, 2017 at 18:51

2 Answers 2

1

Each diff is for each file that are not the same in both branches

The - lines show you the lines that were removed from this file in the first branch and are not in its second branch version

the + lines show you wich lines were added to the file from the second branch and were not in its first branch version

the way it works is every time you change a line of a file it will generate a - and a + like it removed the old line and added a new one even if you changed just one character in the line.

Unprefixed lines are just unchanged and there for context

hope that helps

Sign up to request clarification or add additional context in comments.

14 Comments

So - lines currently only exist in the first branch (master), and + lines currently only exist in the second branch (exportAddsOmits)? There appear to be three files which differ between the two branches, with a list of +'s & -'s for each
The lines at the start of each diff show: diff -- git a/.../views.py b/.../views.py, etc, so presumably a is the first branch that I passed to the diff, i.e. master & b is the second branch that I passed to the diff, i.e. exportAddsOmits?
About the branches that is exactly it
So I've tried switching to master, and adding the lines from exportAddsOmits that were missing, and commenting the lines that had been removed, but when I now try clicking the button that calls this view (the view that displays the page that was broken since I pushed the bug fix to the server), that page is still broken... The error page says: NoReverseMatch at costing/id/adds_omits/, which says: Reverse for 'export_csv' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'costing/(?P<budget_id>[0-9]+)/export-csv/$']
The 'Traceback' shows that the issue is in costing/views.py in the line: return render(request, 'costing/adds_omits.html', context) ... but I can't see what the issue is... any suggestions?
|
1

No matter what you use git diff master exportAddsOmits (- for master branch files, + for exportAddsOmits branch files) or git diff exportAddsOmits master (- for exportAddsOmits branch files, + for master branch files), git will gives you similar output with many difference. Because git diff command gives files difference between two branches. We do sure, files in the two branches are different, so both of the two commands should have output.

When you ran git merge exportAddsOmits, it showed already up-to-date. That is caused by the commit histories between two branch, just like

A---B---C---D              exportAddsOmits
             \
               E---F---G   master

So you should compare the two branches commits difference not files difference. You can use git log exportAddsOmits..master, there will show the commits in master branch but no in exportAddsOmits branch. And git log master..exportAddsOmits will has no output, because exportAddsOmits is older (or we call the parent) than master branch.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.