Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to find how override by code

Suresh thogari June 1, 2023

I have committed some code in my branch. i am able to see in bitbucket portal.

after that when checked my code, my code was removed and i try to find out who done that. but none of the commit is showing the override code.

i would like to know how that is possible. is there any way to commit the code or change the code in bitbucket and will not show in commit section.

please answer.

1 answer

0 votes
Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2023

Hi @Suresh thogari 

There are few creative/destructive ways to "silently override code":

  1. Delete a whole file.
  2. Swap file names.
  3. git reset --hard // DO NOT TRY THIS

And more...

To find the changes, you can try:

  1. BitBucket UI, which allows you to select a file and compare its relevant commits. 
  2. Your IDE - some ide, allow you to get history for code selection.
  3. Git client - use the command "git log -G <regex> path/to/file" to find which commits contain your lost code. You can also add "-c" to get more details.

My personal recommendation is #3 

Suresh thogari June 1, 2023

Hi @Erez Maadani ,

thanks for your reply could you please provide detailed command which you mentioned in point number 3.

git log -G <what is this regex> and what is the path like are you expecting like D:\....\..java something like that..?

Erez Maadani
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 1, 2023

Hi @Suresh thogari 

The regex is a string pattern which describes some of your lost code.

For example, if your lost code includes the line: 

console.log("my-lost-code") 

in a file named: "my-lost-file" in the root directory, running the command:

git log -G "my-lost-code" my-lost-file

Will output all the commits which their diff contains lines with "my-lost-code" in the file "my-lost-file", including the commit the line was removed. 

It's been a while working with windows paths, but depends on your terminal/git client, it will either be "D:\...\..java" or "/D/.../..java". You can also use the "--relative" flag to avoid using full paths. See here for more details: https://git-scm.com/docs/git-log

Suresh thogari June 4, 2023

I am using your command, but nothing is printing in console. will generate any log fil with the command which you given, if yes where can i get the log file. i checked everywhere but did not find.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events