squash | The debugger for microservices | REST library
kandi X-RAY | squash Summary
kandi X-RAY | squash Summary
The debugger for microservices
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of squash
squash Key Features
squash Examples and Code Snippets
Community Discussions
Trending Discussions on squash
QUESTION
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torchvision
from PIL import Image
import matplotlib.pyplot as plt
class Model_Down(nn.Module):
"""
Convolutional (Downsampling) Blocks.
nd = Number of Filters
kd = Kernel size
"""
def __init__(self,in_channels, nd = 128, kd = 3, padding = 1, stride = 2):
super(Model_Down,self).__init__()
self.padder = nn.ReflectionPad2d(padding)
self.conv1 = nn.Conv2d(in_channels = in_channels, out_channels = nd, kernel_size = kd, stride = stride)
self.bn1 = nn.BatchNorm2d(nd)
self.conv2 = nn.Conv2d(in_channels = nd, out_channels = nd, kernel_size = kd, stride = 1)
self.bn2 = nn.BatchNorm2d(nd)
self.relu = nn.LeakyReLU()
def forward(self, x):
x = self.padder(x)
x = self.conv1(x)
x = self.bn1(x)
x = self.relu(x)
x = self.padder(x)
x = self.conv2(x)
x = self.bn2(x)
x = self.relu(x)
return x
...ANSWER
Answered 2021-Jun-11 at 17:50Here is a functional equivalent of the main Model forward(x)
method. It is much more verbose, but it is "unravelling" the flow of operations, making it more easily understandable.
I assumed that the length of the list-arguments are always 5
(i is in the [0, 4] range, inclusive) so I could unpack properly (and it follows the default set of parameters).
QUESTION
Recently I had to squash commits due to several bad commits. Simply doing git pull --rebase origin master
worked for me but my teammate already had merged new history on top of old history. So I want to know is if it is possible to overwrite local history?
Let's say there are three timelines in branches remoteNew
, localOld
and localNew
has hour old commit.
Following works and completely overwrites old history with new history. Though thing to note here is, oldHistory had no new commits after newHistory was created.
...ANSWER
Answered 2021-Jun-06 at 21:05To overwrite local history with remote history, will remove all files, where are only on local history. So be carefully!
QUESTION
I leak a credentials on a file in my feature branch. A reviewer caught the mistake, showing the hash commit, lets call it a6859b6
, when the bad info was introduced and asked me to safely remove. I edited the file, squashed all commits in my branch and forced push.
Then the PR got approved, and merged into master. My branch is deleted on remote and locally. The commit log of master doesn't show any presence of the "bad" commit a6859b6
Surprisingly, querying remote on the exact commit hash https://gitlab.com/blabla/-/commit/a6859b6 still show the offending code.
Is it by design? How do we call this kind of "orphan" commits? What does git do with these and is it possible to purge a specific orphan commit?
EDIT: GitLab answered to my support ticket
Advise to rotate the leak creds.
GitLab has a housekeeping process which prunes the loose commits on the remote repo automatically every 2 weeks
ANSWER
Answered 2021-May-31 at 18:57Is it by design?
Yes, git does not instantly delete objects once they are not referenced. This may be done eventually by the GC (git gc
). Not instantly removing such references makes it easy for you to recover lost data using git reflog
(as long as you have added/committed the data previously).
How do we call this kind of "orphan" commits?
You can call them loose objects/commit. This name is also used in the docs.
What does git do with these and is it possible to purge a specific orphan commit?
Git may eventually decide to clean these up (depending on gc.auto
). This can also be done manually by running git gc --prune=now
in the repository where you want to remove it (you need shell access). If you have a long reference chain referencing the object that is not referenced any more, you may want to add --aggressive
: git gc --aggressive --prune=now
.
If you don't have direct access, you could mirror the repository, run git gc --prune=now
, delete the remote repository, recreate an empty repository and push everything from your local mirror.
Anyways, I would strongly recommend you to change/invalidate the leaked credentials as soon as possible as people could already have downloaded your commit (and the reviewer has seen those, too). When you are sure that your leaked credentials are not valid anywhere, you don't need to worry about unreferenced commits.
QUESTION
I have repo where I don't track .gitignore
, someone committed node_modules
folder and later we decided to untrack it. Now same person(new to git) committed '.gitignore' for few commits before untracking it again. Now we have situation where if we checkout old commits, it deletes several files from repo that were not tracked and it also creates situation where 'vs code' slows down due to thousands of untracked files. What's the best way to handle this situation? I think I will need to squash those commits and keep them on seperate branch so no one checks it out accidentally. Do I have any other options?
As things happened,
...ANSWER
Answered 2021-Jun-02 at 13:29Form what you have described top of master
is fixed and problem is only is someone checks out old version of code where stuff are broken.
There is no easy way to fix it. For that you need rewrite whole history and make sure that all copies of repository are updated with new history. This is organization nightmare you will always miss one repo which will be pushed back to main repository and you will come back to initial state. So do not try that.
The only reasonable solution is address scenario when someone checks out old version of code. If this is some branch, like: release-1.x.x
then just cherry pick a commit which fixes this issue to that branch.
If developers have to checkout code to specific version/commit, they have to live with this problem as long this version of code needs some maintenance.
Important is to learn some lesson from this kind of problems:
- always create and check in
.gitignore
to repository when only you start new project. - git hooks are a bit harder to configure, but are great solution to protect repo from unwanted corruptions
- note there are tools github/gitlab/bitbucket/... which allows you to configure pull requests and configure git hooks to protect specific branches. Passing pull request code review is great way to protect you from unexpected (not covered by
.gitignore
and git hooks) bad changes
- note there are tools github/gitlab/bitbucket/... which allows you to configure pull requests and configure git hooks to protect specific branches. Passing pull request code review is great way to protect you from unexpected (not covered by
- when intern is joining a project make sure his git skills are at least a basic and he understands what should be tracked by repository and what should not be tracked.
QUESTION
I have a scenario where I have made a branch off master, lets call it A, made some changes. Then had to branch off A, let call it B, and made some more changes. I then merged B into A, so now A has both the commits from A and B.
I now need to rebase branch A onto master and squash the commit from branch B, but when I do this I lose all the changes that were on branch B and only the changes from branch A are there.
I am wondering how do I rebase onto master squash the commits and still have all the changes?
...ANSWER
Answered 2021-May-30 at 22:52If you want to squash the commits from B, then:
- rebase B onto A first
- squash B so now it is a single (or similar) commit on top of A
- rebase A onto master
QUESTION
On a daily basis I am working with GitLab with following workflow:
- I create a new
feature
branch frommain
branch - I commit and push changes to the
feature
branch - Then I create a new merge request (from
feature
intomain
) via GitLab GUI usingsquash
feature: - When approver accept my MR, it results with following
main
branch tree (from IntellJ IDEA):
I have tried to achieve the same on my testing repository using command line only but with no success so far. I have tried (on feature
branch) interactive rebase as well as soft reset with force push but it always results as a 'single line tree'. Example after two separate merges from feature
into main
:
ANSWER
Answered 2021-May-29 at 12:15Simply use merge without fast-forward:
QUESTION
I've successfully implemented automatic file creation/update via Github V3 Rest API, however the only downside is that for each file I have a commit.
There is a possibility to do the same for multiple files, but unfortunately it involves some concepts I still haven't mastered and it will take me some time until I get there since I have more urgents stuff on my TODO list.
In the meanwhile, I can totally live with that or simply squash the last N commits, which I imagined should be relatively easy, since locally it's just a matter of
...ANSWER
Answered 2021-May-11 at 07:41I did not see a squash feature directly through API.
You would need to:
- create a branch at HEAD-N commits, through the create ref API
- reset your current branch to HEAD-N sha, with force boolean parameter set to true?
- create a pull request from your new branch to your old reset branch
- merge the PR, with the
merge_method
parameter set to squash
Pretty convoluted, but it should work (entirely through script, without having to clone the repository).
QUESTION
If new people are using git sometimes they add files, and delete files on their branch, not realizing the deleted files stay in the history.
How does one protect the deleted files from going into the main / dev branch, and increasing the repo size.
I realize squashing the commits would do this, but is there a way to git diff and show deleted / undeleted files on their branch to detect this?
...ANSWER
Answered 2021-May-28 at 07:52If you intend to take each new commit from someone who offers you 50 commits (or any other number than 1), you must inspect each new commit. There is no Royal Road to this: it requires inspecting each commit.
If you intend to use git merge --squash
or similar to convert all 50 of their commits into a single, new, different commit that just produces the same end result, then you can review the changes as a single change that produces the same end result, since that's what you will add to your repository.
That's really all there is to this. Pick what you are going to do, and review accordingly.
QUESTION
I'm trying to undo my bad git practices from times past and in doing so, I want to get a list of commits to specific files, newer than a certain timestamp (older commits to these files were cherry-picked to the master branch, which I now realise was a very bad idea, considering that the originating branch was nowhere near finished). Illustrated simplified:
...ANSWER
Answered 2021-May-27 at 01:02Every commit has two date-and-time stamps. One is called the author date and one is called the committer date.
When you make a new commit in the usual way, using git commit
and no trickery, both are set to the same value. Git retrieves the current time from your computer clock, and if that's accurate, the new commit's two date-stamps are "now".
When you make a commit using git cherry-pick
or something that internally uses the cherry-pick machinery (such as git rebase
), Git normally preserves the original author of the commit, and the original author-date. You become the committer, and "now" is the committer date.
To see both time stamps with git log
, use any of the formatting options that prints both. The simplest to use is git log --pretty=fuller
.
The --since
and --until
(or --after
and --before
) options to git log
use the committer date only. (I think there should be a way to specify author dates, but there isn't.)
QUESTION
ANSWER
Answered 2021-May-25 at 21:12How can I get same HEAD for master and dev after merge?
You can't. Well, technically you could, but you probably don't want to.
A branch in git points to a commit; that commit points to other commits, back through history. Each of those commits is identified by a unique hash; if two different commits had the same hash, everything would be horribly broken. That hash covers both the contents of the repository, and all the metadata of the commit, including what parents it has.
So if two different branches point at the same hash, those branches are identical - not just identical in their current content, but identical in their entire history.
The only way for that to happen is to always use "fast-forward" merges, everywhere, so that all your branches are actually just pointers in a single line of commits. In practice, that means rebasing things, a lot - for instance, every hotfix will probably require rebasing the whole of develop, and then rebasing all open feature branches onto that new develop.
That's a lot of work, and a lot of things that can go wrong, to avoid this:
I had to merge an empty commit with no diff.
Git was smart enough to recognise that no actual changes were needed, even though you'd merged two unrelated commits (remember: a squash merge throws away all history on the feature branch). That is it solving the problem for you.
The other solution, as pointed out in comments, is not to merge the feature to two places in the first place. Merge release to master, and then merge master to develop.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install squash
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page