git push from another computer to the same file/ref/project
I clone my project on another computer now i want to push it tells me to add a remote so i did. Again i try to push now I got this (see images)
I try to push like this: git push --set-upstream pp6 main Which method is the best git hard push, fork etc ...
$ git push --set-upstream pp6 main
To https://github.com/ogras-yasin/p6
! [rejected] main -> main (fetch first)
error: failed to push some refs to 'https://github.com/ogras-yasin/p6'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
do you know?
how many words do you know
See also questions close to this topic
-
Can't clone from repository of Github in Visual Studio
Recently, my visual studio can't clone from repository of GitHub.
Once it is completed clone, the visual studio will report this error "One or more errors occurred":
I cannot find any error in the output windows in visual studio.
And then, the Git Changes is blank. I can't pull and push any.
Previously I considered maybe it is the problem of my Visual Studio or Operation System.
However, after I reinstalled my Visual Studio and even reinstalled my Operation System, the problem is still here.
Soon I found a topic may relate my problem:Git has stopped working after installing VS 2022
Whereas, I tried all the ways in it and it doesn't work any.
The version of my Visual Studio is 2022 17.1.6. What's wrong with it?
-
Change CRLF to LF of all the files in repo
My repo has lots of files with CRLF. I want them to be changed to LF.
I tried to change in my working copy and commit them but the changes are ignored by git. The files with only change eol can be staged but can't be committed, right?
I can change eol and add another change on the first commit then I revert the change except for eol before next commit. But it's so dirty solution.
Why does git ignore the eol changes? Any good workaround for this?
I know
core.eol
andcore.autocrlf
in config and* text=auto
in .gitattributes but they don't help me. -
What to do when suddenly git no longer see any change in any file?
I was using git on a Laravel project but suddenly git no longer see the changes I make in any of my files. What can I do ?
-
Oracle DBD with 19c - forked child hangs on exit
We just upgraded one of our database servers from Oracle 12.2.0.1 to 19.15.0 and one our perl programs is behaving differently. We are running with RedHat 8.4 using Perl v5.26.3 and the latest DBD::Oracle and DBI from cpan.
Under 19c, a forked child hangs on exit if the parent has (or had) an oracle connection where the connection handle is a global (using 'our'). This does not happen if the connection handle is a local (declared with 'my'). When running against a 12c database, with DBD::Oracle using 12c libraries, the child process exits normally regardless of how the variable is 'declared'.
Note also that this issue does not happen if the child exec's another program.
The block of code below exhibits the issue in our environment. This is just a simplification. The real code uses packages and so the connection handle needs to be a global.
Any help appreciated.
use strict; use warnings; use DBI; # If $dbh declared with my, this works witn 19c # otherwise, exit in child below never returns our $dbh = DBI->connect('dbi:Oracle:ORCL', 'scott', 'tiger', { RaiseError => 1, AutoCommit => 0, PrintError => 0, InactiveDestroy => 0 }); print "Connected to db\n"; $dbh->disconnect; #undef $dbh; # Child process exits normally if this uncommented my $pid; $pid = fork; if( $pid == 0 ) { print "This is child process\n"; print "Child process exiting now\n"; exit 0; # Never returns if $dbh is a global } print "This is parent process and child ID is $pid\n"; print "Parent Waiting on child\n"; my $chldPid = wait; print "Parent done. Child pid $chldPid has completed\n"; exit 0;
-
Different C++ fork() behavior between CentOS 7.5 & RockyLinux 8.4, Ubunu 20.04
I'm working with some legacy code. It works fine on a CentOS 7 system. The args array gets hosed on both a Rocky 8.4 and Ubuntu 20.04 system. I've simplified the problem and added print statements. The execv() was launching another program. The args going into the execv get messed up. Without the fork, the code works as expected. Baffled.
I have two simple test programs, one of which does nothing.
test9.cpp
int main(){}
and test10.cpp
#include <iostream> #include <string> #include <vector> #include <unistd.h> int main() { std::vector<std::string> stringArgs; std::string a{"./test9.x"}; std::string b{"test10.cpp"}; stringArgs.push_back(a); stringArgs.push_back(b); char* args[stringArgs.size()+1]; if(fork() == 0){ for(uint8_t i = 0; i < stringArgs.size(); i++) { std::string tmp(stringArgs[i]); args[i] = const_cast<char*>(tmp.c_str()); std::cout << "\n\t"<<args[i]<<"'\n\n"; } std::cout << "\n\t"<<args[0]<<"'\n\n"; std::cout << "\n\t"<<args[1]<<"'\n\n"; // last argument has to be NULL args[stringArgs.size()] = NULL; execv(args[0],&args[0]); std::cout << "\n\tERROR: Could not run '"<<args[0]<<"'\n\n"; } else std::cout<<"parent\n"; }
g++ -o test9.x test9.cpp; g++ -o test10.x test10.cpp
On the CentOS 7 I get:
$ ./test10.x ./test9.x test10.cpp ./test9.x test10.cpp parent
And on both Rocky Linux 8.4 and Ubuntu 20.04 I get this. Notice the test9.x gets replaced by test10.cpp after the for loop.
./test10.x parent ./test9.x test10.cpp test10.cpp test10.cpp ERROR: Could not run test10.cpp
-
/usr/bin/cat: -: Bad file descriptor when using pipe()
I am recreating a complete shell. For that I must simulate "|". To do this, I have to use the dup2(), fork() and pipe() functions.
here is my code :
void do_pipe(global *glob, char *command_in_line) { char **left = my_str_to_word_array(give_left_commande(command_in_line)); char **right = my_str_to_word_array(give_right_commande(command_in_line)); int i = 0; glob->pipe.pipe = 1; glob->pipe.pipe_status = DROITE; glob->commande = right; glob->fd = glob->pipe.pipefd[0]; glob->origine = 0; distribe_commande(glob); glob->pipe.pipe_status = GAUCHE; glob->commande = left; glob->fd = glob->pipe.pipefd[1]; glob->origine = 1; distribe_commande(glob); while (waitpid(glob->pipe.pid_right, &glob->pipe.status_right, 0) != -1 && !WIFEXITED(glob->pipe.status_right)) error_execve(glob->pipe.status_right); while (waitpid(glob->pipe.pid_left, &glob->pipe.status_left, 0) != -1 && !WIFEXITED(glob->pipe.status_left)) error_execve(glob->pipe.status_left); glob->pipe.pipe_status = NEUTRE; }
The fonction
distribe_commande()
lead to a formafting of the command with his path etc... . Then, it will execute the command with this code :void execve_neutre(global *glob) { if (glob->pipe.pid == 0) { dup2(glob->fd, glob->origine); close(glob->pipe.pipefd[0]); close(glob->pipe.pipefd[1]); if (execve(glob->commande[0], glob->commande, glob->env) == -1) { exit(0); } } while (waitpid(glob->pipe.pid, &glob->pipe.status, 0) != -1 && !WIFEXITED(glob->pipe.status)) error_execve(glob->pipe.status); } void execve_gauche(global *glob) { if (glob->pipe.pid_left == 0) { dup2(glob->fd, glob->origine); close(glob->pipe.pipefd[0]); close(glob->pipe.pipefd[1]); if (execve(glob->commande[0], glob->commande, glob->env) == -1) { exit(0); } } } void execve_droite(global *glob) { if (glob->pipe.pid_right == 0) { dup2(glob->fd, glob->origine); close(glob->pipe.pipefd[0]); close(glob->pipe.pipefd[1]); if (execve(glob->commande[0], glob->commande, glob->env) == -1) { exit(0); } } } int do_execve(global *glob) { if (glob->pipe.pipe != 1) { glob->pipe.pid = fork(); execve_neutre(glob); return 0; } if (glob->pipe.pipe == 1 && glob->pipe.pipe_status == DROITE) { glob->pipe.pid_right = fork(); execve_droite(glob); return 0; } if (glob->pipe.pipe == 1 && glob->pipe.pipe_status == GAUCHE) { glob->pipe.pid_left = fork(); execve_gauche(glob); return 0; } return 0; }
When I write
ls | cat -e
, the output is$~> ls | cat -e 42sh build CMakeLists.txt hello include Jenkinsfile lib main.c Makefile src /usr/bin/cat: -: Bad file descriptor /usr/bin/cat: closing standard input: Bad file descriptor
Do you know what caused this ?
Thanks in advance for your answers.
-
Clone Android tablet
I have 200 android tablets all the same make and model and identical. I want to get one of them and install a few apps and make changes to some settings and so on and basically personalize it and then create an image of this device and clone it to all other 199 devices. This is to avoid the time that is required to personalize all the devices one at the time. These are MTK base and I can use SP Flash Tool to load an image to them but I don't know how to build an image from one and then load it to others.
Thanks,
-
Need help creating multiple clones of an image in pygame
I'm very new to pygame, so sorry if this is a basic question. My problem is that when I create clones in my while loop, I blit them in my while loop. The problem with this is that the code that fills my screen is also in my while loop, resulting in a flickering effect, where the clones appear and disappear over and over, never moving. I'm trying to create these clones to follow the player and need help, thank you in advance.
# Imports import os import math import pygame import random # Initialize pygame modules pygame.init() # Fonts ########################################################## ########################################################## #################### CONSTANTS ##################### ########################################################## ########################################################## # SCREEN RES WIDTH, HEIGHT = 900, 500 WINDOW = pygame.display.set_mode((WIDTH, HEIGHT)) pygame.display.set_caption("Bullet Hell") # CLOCK clock = pygame.time.Clock() # FONTS # VELOCITY velocity = 6 # COLORS WHITE = (255, 255, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) YELLOW = (255, 255, 0) GREEN = (15, 107, 56) BROWN = (122, 98, 80) TRANSPARENT = (0, 0, 0, 0) ########################################################## ########################################################## #################### VARIABLES ##################### ########################################################## ########################################################## # FPS FPS = 60 # ASSET IMAGES survivorImage = pygame.image.load(os.path.join('Assets', 'survivor.png')) survivorImage = pygame.transform.scale(survivorImage, (90, 90)) greenSlime = pygame.image.load(os.path.join('Assets', 'slime_green.png')) greenSlime = pygame.transform.scale(greenSlime, (60, 60)) ########################################################## ########################################################## ##################### CLASSES ###################### ########################################################## ########################################################## class Player: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height self.movingRight = False self.movingLeft = False self.movingUp = False self.movingDown = False # CREATE PLAYER + ROTATE PLAYER TO INPUT def InitializePlayer(self, WINDOW): # MAKE PLAYER FACE LEFT WHEN GOING LEFT if self.movingLeft: self.movingRight = False WINDOW.blit(pygame.transform.flip(survivorImage, True, False), (self.x, self.y)) # MAKE PLAYER FACE RIGHT WHEN GOING RIGHT elif self.movingRight: self.movingLeft = False WINDOW.blit(survivorImage, (self.x, self.y)) # MAKE PLAYER FACE UP WHEN MOVING UP elif self.movingUp: self.movingDown = False if self.movingRight: WINDOW.blit(pygame.transform.rotate(survivorImage, 90), (self.x, self.y)) self.movingRight = False elif self.movingLeft: WINDOW.blit(pygame.transform.rotate(survivorImage, 270), (self.x, self.y)) self.movingLeft = False # PREVENTS PLAYER FROM BEING INVISIBLE AT START else: WINDOW.blit(pygame.transform.rotate(survivorImage, 90), (self.x, self.y)) # MAKE PLAYER FACE DOWN WHEN MOVING DOWN elif self.movingDown: self.movingUp = False if self.movingRight: WINDOW.blit(pygame.transform.rotate(survivorImage, -90), (self.x, self.y)) self.movingRight = False elif self.movingLeft: WINDOW.blit(pygame.transform.rotate(survivorImage, -270), (self.x, self.y)) self.movingLeft = False # PREVENTS PLAYER FROM BEING INVISIBLE AT START else: WINDOW.blit(pygame.transform.rotate(survivorImage, -90), (self.x, self.y)) # DISPLAY PLAYER TO SCREEN else: WINDOW.blit(survivorImage, (self.x, self.y)) # PLAYER MOVEMENT def PlayerMovement(self, keysPressed, x, y): # LEFT if keysPressed[pygame.K_a] and self.x - velocity > 0: self.x -= velocity self.movingLeft = True self.movingRight = False for bullet in bulletList: bullet.x += 5 # RIGHT if keysPressed[pygame.K_d] and self.x + self.width + velocity < 900: self.x += velocity self.movingRight = True self.movingLeft = False for bullet in bulletList: bullet.x -= 5 # UP if keysPressed[pygame.K_w] and self.y - velocity > 0: self.y -= velocity self.movingUp = True self.movingDown = False self.movingRight = False self.movingLeft = False for bullet in bulletList: bullet.y += 5 # DOWN if keysPressed[pygame.K_s] and self.y + self.height + velocity < 500: self.y += velocity self.movingUp = False self.movingDown = True self.movingRight = False self.movingLeft = False for bullet in bulletList: bullet.y -= 5 # CLASS FOR SHOOTING BULLETS class PlayerBullets: def __init__(self, x, y, mouseX, mouseY): self.x = x self.y = y self.mouseX = mouseX self.mouseY = mouseY self.speed = 15 # atan2 sends back the angle in radians self.angle = math.atan2(y-mouseY, x-mouseX) self.xVelocity = math.cos(self.angle) * self.speed self.yVelocity = math.sin(self.angle) * self.speed # DRAWS BULLETS ONSCREEN def CreateBullet(self, display): self.x -= int(self.xVelocity) self.y -= int(self.yVelocity) pygame.draw.circle(display, BLACK, (self.x + 30, self.y + 20), 5) # INSTANTIATE PLAYER player = Player(400, 200, 90 ,90) # BULLETS LIST bulletList = [] # SLIME ENEMY CLASS class SlimeEnemy: def __init__(self, x, y): self.x = x self.y = y # DRAWS SLIME def InitializeSlime(self, WINDOW): for i in range(5): WINDOW.blit(greenSlime, (random.randrange(100, 400), 200)) # follows player duh def FollowPlayer(self): global player if self.x < player.x: self.x += 2 if self.x > player.x: self.x -= 2 if self.y > player.y: self.y -= 2 if self.y < player.y: self.y += 2 # INSTANTIATE SLIME #greenSlimeEnemy = SlimeEnemy(-200, 200) slimeList = [] for i in range(5): greenSlimeEnemy = SlimeEnemy(0, 0) # MAIN GAME LOOP def main(): global player running = True while running: slimesInitialized = False WINDOW.fill(BROWN) clock.tick(FPS) mouse_X, mouse_Y = pygame.mouse.get_pos() # QUITS THE GAME for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.quit() # CREATES BULLETS ON LEFT MOUSE CLICK if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 1: bulletList.append(PlayerBullets(player.x, player.y, mouse_X, mouse_Y)) for bullet in bulletList: bullet.CreateBullet(WINDOW) # REMOVES BULLETS WHEN THEY GO OFFSCREEN if bullet.y < 0 or bullet.y > HEIGHT or bullet.x < 0 or bullet.x > WIDTH: bulletList.remove(bullet) # Gets key inputs for player movement keysPressed = pygame.key.get_pressed() # Function calling if slimesInitialized == False: greenSlimeEnemy.InitializeSlime(WINDOW) slimesInitialized = True player.InitializePlayer(WINDOW) player.PlayerMovement(keysPressed, player.x, player.y) greenSlimeEnemy.FollowPlayer() pygame.display.update() if __name__ == "__main__": main()