P
P
PEKTOP2014-05-15 16:47:54
MySQL
PEKTOP, 2014-05-15 16:47:54

Why did git pull start saving files as root?

On the server I do:
git clone [email protected]:app.gitand I drag out the project, but then when I do git pullall the files that have been changed or created become root, and during the first operation they were created on behalf of an ordinary ubuntu linux user.

Answer the question

In order to leave comments, you need to log in

7 answer(s)
N
nozzy, 2015-11-18
@battrack

Didn't check:

select
c.count_id,
t.balance
from counts c 
left join 
(
    select  o.operation_count_id,  o.balance   
    from operation o 
    where o.date_count = (select max(date_count) 
                  from operation 
                  where operation_count_id = o.operation_count_id)
    
) t on t.operation_count_id = c.count_id

C
Cat Anton, 2015-11-18
@27cm

stackoverflow.com/questions/612231/how-can-i-selec...

D
Dmitry Kovalsky, 2015-11-18
@dmitryKovalskiy

There is another option. Make 2 requests. In the first - in a temporary table to save the result of a query like
And with the second query, make your select but join this temporary table, and not the entire table of operations.

I
igruschkafox, 2015-11-18
@igruschkafox

-- Создали таблицы
CREATE TABLE counts (count_id INT IDENTITY (1,1) , count_name nVARCHAR(20))
CREATE TABLE operation  (operation_id INT IDENTITY (1,1) ,operation_count_id INT, balance MONEY,operation_date DATETIME ,operation_name NVARCHAR(50))

go
-- Очищаем таблицы
TRUNCATE TABLE counts
TRUNCATE TABLE operation

-- Заполняем данным
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Первый счет')
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Второй счет')
INSERT INTO [dbo].[counts] ([count_name]) VALUES ('Третий счет')

INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'10.3','01-01-2015','Первая операция по первому счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'25.5','02-02-2015','Вторая операция по первому счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(1,'34.4','03-03-2015','Третья операция по первому счету')

INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(2,'11.7','01-01-2015','Первая операция по Второму счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(2,'22.2','04-04-2015','Вторая операция по Второму счету')

INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(3,'33.1','01-01-2015','Первая операция по Тертья счету')
INSERT INTO [dbo].[operation]([operation_count_id],[balance],[operation_date],[operation_name])VALUES(3,'33.7','02-02-2015','Вторая операция по Третья счету')


-- Запрос возвращает баланс последней операции по каждому счету
SELECT c.count_id,c.count_name
,o2.balance
,o2.operation_name
 FROM counts c
 JOIN (
SELECT operation_count_id,
 MAX(operation_date)  AS 'Max Date'
FROM dbo.operation 
GROUP BY operation_count_id

) o ON o.operation_count_id=c.count_id
JOIN dbo.operation o2 ON o2.operation_count_id=o.operation_count_id AND o2.operation_date=o.[Max Date]

R
Ruslan Fedoseev, 2015-11-18
@martin74ua

SELECT * FROM counts c LEFT JOIN operation o ON (c.count_id=operation_count_id) order by operation_time desc limit 1
like so.

A
AlikDex, 2015-11-18
@AlikDex

SELECT * 
FROM counts AS c 
LEFT JOIN operation AS o ON (c.count_id=(
   SELECT operation_count_id 
   FROM operation 
   ORDER by date
   LIMIT 1) o
)

In case id = always the latest date (i.e. the order is never broken), you can do this:
SELECT * 
FROM counts AS c 
LEFT JOIN operation AS o ON (c.count_id=(
   SELECT MAX(operation_count_id) 
   FROM operation) o
)

upd: I put the parenthesis incorrectly.

K
kichkiruk_v, 2014-06-05
@kichkiruk_v

Turn your eyes to hooks, they can be executed on behalf of the root.
*you can add a line chown user:group /way2project/* -R

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question